From 937e11259c1f32ce50811415083bdf5c4601fc0f Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Fri, 19 Apr 2024 07:43:50 +1000 Subject: [PATCH] [#768] Added checking for bin existence in scripts. (#1276) Co-authored-by: tan.nguyen --- scripts/drevops/deploy-docker.sh | 6 ++++++ scripts/drevops/deploy-lagoon.sh | 5 +++++ scripts/drevops/deploy-webhook.sh | 6 ++++++ scripts/drevops/doctor.sh | 5 +++++ scripts/drevops/download-db-acquia.sh | 5 +++++ scripts/drevops/download-db-curl.sh | 6 ++++++ scripts/drevops/download-db-docker-registry.sh | 6 ++++++ scripts/drevops/download-db-ftp.sh | 6 ++++++ scripts/drevops/download-db-lagoon.sh | 5 +++++ scripts/drevops/export-db-docker.sh | 6 ++++++ scripts/drevops/export-db.sh | 6 ++++++ scripts/drevops/github-labels.sh | 6 ++++++ scripts/drevops/login-docker.sh | 6 ++++++ scripts/drevops/mirror-code.sh | 5 +++++ scripts/drevops/notify-github.sh | 6 +++++- scripts/drevops/notify-jira.sh | 6 +++++- scripts/drevops/notify-newrelic.sh | 7 ++++++- scripts/drevops/reset.sh | 6 ++++++ scripts/drevops/setup-ssh.sh | 5 +++++ scripts/drevops/task-copy-db-acquia.sh | 6 +++++- scripts/drevops/task-copy-files-acquia.sh | 9 ++++++--- scripts/drevops/task-custom-lagoon.sh | 5 +++++ scripts/drevops/task-purge-cache-acquia.sh | 9 ++++++--- scripts/drevops/update-scaffold.sh | 5 +++++ 24 files changed, 133 insertions(+), 10 deletions(-) diff --git a/scripts/drevops/deploy-docker.sh b/scripts/drevops/deploy-docker.sh index edce19a37..e21e7e8d9 100755 --- a/scripts/drevops/deploy-docker.sh +++ b/scripts/drevops/deploy-docker.sh @@ -39,6 +39,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +#shellcheck disable=SC2043 +for cmd in docker; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + info "Started DOCKER deployment." # Only deploy if the map was provided, but do not fail if it has not as this diff --git a/scripts/drevops/deploy-lagoon.sh b/scripts/drevops/deploy-lagoon.sh index f90c236ce..0ec321259 100755 --- a/scripts/drevops/deploy-lagoon.sh +++ b/scripts/drevops/deploy-lagoon.sh @@ -102,6 +102,11 @@ if ! command -v lagoon >/dev/null || [ -n "${DREVOPS_LAGOONCLI_FORCE_INSTALL}" ] export PATH="${PATH}:${DREVOPS_LAGOONCLI_PATH}" fi +for cmd in lagoon curl; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + note "Configuring Lagoon instance." #shellcheck disable=SC2218 lagoon config add --force -l "${DREVOPS_DEPLOY_LAGOON_INSTANCE}" -g "${DREVOPS_DEPLOY_LAGOON_INSTANCE_GRAPHQL}" -H "${DREVOPS_DEPLOY_LAGOON_INSTANCE_HOSTNAME}" -P "${DREVOPS_DEPLOY_LAGOON_INSTANCE_PORT}" diff --git a/scripts/drevops/deploy-webhook.sh b/scripts/drevops/deploy-webhook.sh index 80cd772e7..9e360a1f5 100755 --- a/scripts/drevops/deploy-webhook.sh +++ b/scripts/drevops/deploy-webhook.sh @@ -31,6 +31,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +#shellcheck disable=SC2043 +for cmd in curl; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + info "Started WEBHOOK deployment." # Check all required values. diff --git a/scripts/drevops/doctor.sh b/scripts/drevops/doctor.sh index 2c9fd9998..40426916b 100755 --- a/scripts/drevops/doctor.sh +++ b/scripts/drevops/doctor.sh @@ -72,6 +72,11 @@ fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 warn() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[33m[WARN] %s\033[0m\n" "${1}" || printf "[WARN] %s\n" "${1}"; } # @formatter:on +for cmd in docker pygmy ahoy; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + # # Main entry point. # diff --git a/scripts/drevops/download-db-acquia.sh b/scripts/drevops/download-db-acquia.sh index 89c7c6def..9469d6cb7 100755 --- a/scripts/drevops/download-db-acquia.sh +++ b/scripts/drevops/download-db-acquia.sh @@ -55,6 +55,11 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +for cmd in php curl gunzip; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + info "Started database dump download from Acquia." # diff --git a/scripts/drevops/download-db-curl.sh b/scripts/drevops/download-db-curl.sh index 2d7a68001..94f300ba9 100755 --- a/scripts/drevops/download-db-curl.sh +++ b/scripts/drevops/download-db-curl.sh @@ -30,6 +30,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +#shellcheck disable=SC2043 +for cmd in curl; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + info "Started database dump download from CURL." # Check all required values. diff --git a/scripts/drevops/download-db-docker-registry.sh b/scripts/drevops/download-db-docker-registry.sh index f3cd13bd6..e4e7d7f8c 100755 --- a/scripts/drevops/download-db-docker-registry.sh +++ b/scripts/drevops/download-db-docker-registry.sh @@ -33,6 +33,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +#shellcheck disable=SC2043 +for cmd in docker; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + info "Started Docker data image download." [ -z "${DOCKER_USER}" ] && fail "Missing required value for DOCKER_USER." && exit 1 diff --git a/scripts/drevops/download-db-ftp.sh b/scripts/drevops/download-db-ftp.sh index b28eed2bd..f17b187f3 100755 --- a/scripts/drevops/download-db-ftp.sh +++ b/scripts/drevops/download-db-ftp.sh @@ -41,6 +41,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +#shellcheck disable=SC2043 +for cmd in curl; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + # Check all required values. [ -z "${DREVOPS_DB_DOWNLOAD_FTP_USER}" ] && fail "Missing required value for DREVOPS_DB_DOWNLOAD_FTP_USER." && exit 1 [ -z "${DREVOPS_DB_DOWNLOAD_FTP_PASS}" ] && fail "Missing required value for DREVOPS_DB_DOWNLOAD_FTP_PASS." && exit 1 diff --git a/scripts/drevops/download-db-lagoon.sh b/scripts/drevops/download-db-lagoon.sh index e7798157c..c071cca51 100755 --- a/scripts/drevops/download-db-lagoon.sh +++ b/scripts/drevops/download-db-lagoon.sh @@ -76,6 +76,11 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +for cmd in ssh rsync; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + info "Started database dump download from Lagoon." mkdir -p "${DREVOPS_DB_DIR}" diff --git a/scripts/drevops/export-db-docker.sh b/scripts/drevops/export-db-docker.sh index 86735080f..444a682e0 100755 --- a/scripts/drevops/export-db-docker.sh +++ b/scripts/drevops/export-db-docker.sh @@ -33,6 +33,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +#shellcheck disable=SC2043 +for cmd in docker; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + info "Started Docker database image export." [ -z "${DREVOPS_DB_EXPORT_DOCKER_IMAGE}" ] && fail "Destination image name is not specified. Please provide docker image as a variable DREVOPS_DB_EXPORT_DOCKER_IMAGE in a format /." && exit 1 diff --git a/scripts/drevops/export-db.sh b/scripts/drevops/export-db.sh index 20b02c13b..417182e0a 100755 --- a/scripts/drevops/export-db.sh +++ b/scripts/drevops/export-db.sh @@ -25,6 +25,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +#shellcheck disable=SC2043 +for cmd in docker; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + info "Started database export." if [ -z "${DREVOPS_DB_DOCKER_IMAGE}" ]; then diff --git a/scripts/drevops/github-labels.sh b/scripts/drevops/github-labels.sh index af269f8ab..618fcaec1 100755 --- a/scripts/drevops/github-labels.sh +++ b/scripts/drevops/github-labels.sh @@ -35,6 +35,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +#shellcheck disable=SC2043 +for cmd in curl; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + # Array of labels to create. If DELETE_EXISTING_LABELS=1, the labels list will # be exactly as below, otherwise labels below will be added to existing ones. labels=( diff --git a/scripts/drevops/login-docker.sh b/scripts/drevops/login-docker.sh index b087f3a31..b4f7cbeb2 100755 --- a/scripts/drevops/login-docker.sh +++ b/scripts/drevops/login-docker.sh @@ -29,6 +29,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +#shellcheck disable=SC2043 +for cmd in docker; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + # Check all required values. [ -z "${DOCKER_REGISTRY}" ] && echo "Missing required value for DOCKER_REGISTRY." && exit 1 diff --git a/scripts/drevops/mirror-code.sh b/scripts/drevops/mirror-code.sh index 639395775..17b4567e4 100755 --- a/scripts/drevops/mirror-code.sh +++ b/scripts/drevops/mirror-code.sh @@ -44,6 +44,11 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +for cmd in git rsync; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + info "Started code mirroring." # Check all required values. diff --git a/scripts/drevops/notify-github.sh b/scripts/drevops/notify-github.sh index e489451d7..bbbe3b15d 100755 --- a/scripts/drevops/notify-github.sh +++ b/scripts/drevops/notify-github.sh @@ -43,7 +43,11 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on -command -v curl >/dev/null || (fail "curl command is not available." && exit 1) +for cmd in php curl; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + [ -z "${DREVOPS_NOTIFY_GITHUB_TOKEN}" ] && fail "Missing required value for DREVOPS_NOTIFY_GITHUB_TOKEN" && exit 1 [ -z "${DREVOPS_NOTIFY_REPOSITORY}" ] && fail "Missing required value for DREVOPS_NOTIFY_REPOSITORY" && exit 1 [ -z "${DREVOPS_NOTIFY_REF}" ] && fail "Missing required value for DREVOPS_NOTIFY_REF" && exit 1 diff --git a/scripts/drevops/notify-jira.sh b/scripts/drevops/notify-jira.sh index bbe22a649..6bbf185f5 100755 --- a/scripts/drevops/notify-jira.sh +++ b/scripts/drevops/notify-jira.sh @@ -53,7 +53,11 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on -command -v curl >/dev/null || (fail "curl command is not available." && exit 1) +for cmd in php curl; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + [ -z "${DREVOPS_NOTIFY_JIRA_USER}" ] && fail "Missing required value for DREVOPS_NOTIFY_JIRA_USER" && exit 1 [ -z "${DREVOPS_NOTIFY_JIRA_TOKEN}" ] && fail "Missing required value for DREVOPS_NOTIFY_JIRA_TOKEN" && exit 1 [ -z "${DREVOPS_NOTIFY_BRANCH}" ] && fail "Missing required value for DREVOPS_NOTIFY_BRANCH" && exit 1 diff --git a/scripts/drevops/notify-newrelic.sh b/scripts/drevops/notify-newrelic.sh index 97ffb9fa4..2db0a7074 100755 --- a/scripts/drevops/notify-newrelic.sh +++ b/scripts/drevops/notify-newrelic.sh @@ -52,7 +52,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on -command -v curl >/dev/null || (fail "curl command is not available." && exit 1) +#shellcheck disable=SC2043 +for cmd in curl; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + [ -z "${DREVOPS_NOTIFY_NEWRELIC_PROJECT}" ] && fail "Missing required value for DREVOPS_NOTIFY_NEWRELIC_PROJECT" && exit 1 [ -z "${DREVOPS_NOTIFY_NEWRELIC_APIKEY}" ] && fail "Missing required value for DREVOPS_NOTIFY_NEWRELIC_APIKEY" && exit 1 [ -z "${DREVOPS_NOTIFY_NEWRELIC_REF}" ] && fail "Missing required value for DREVOPS_NOTIFY_NEWRELIC_REF" && exit 1 diff --git a/scripts/drevops/reset.sh b/scripts/drevops/reset.sh index 97579dbf5..7784750f6 100755 --- a/scripts/drevops/reset.sh +++ b/scripts/drevops/reset.sh @@ -18,6 +18,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +#shellcheck disable=SC2043 +for cmd in git; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + is_hard_reset="$([ "${1:-}" == "hard" ] && echo "1" || echo "0")" info "Started reset." diff --git a/scripts/drevops/setup-ssh.sh b/scripts/drevops/setup-ssh.sh index 9e15d0b75..032f4a834 100755 --- a/scripts/drevops/setup-ssh.sh +++ b/scripts/drevops/setup-ssh.sh @@ -33,6 +33,11 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +for cmd in ssh-keygen ssh-add; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + info "Started SSH setup." fingerprint_var="DREVOPS_${DREVOPS_SSH_PREFIX}_SSH_FINGERPRINT" diff --git a/scripts/drevops/task-copy-db-acquia.sh b/scripts/drevops/task-copy-db-acquia.sh index dd9e948c9..7abc3cba7 100755 --- a/scripts/drevops/task-copy-db-acquia.sh +++ b/scripts/drevops/task-copy-db-acquia.sh @@ -71,7 +71,11 @@ extract_json_value() { } # Pre-flight checks. -command -v curl >/dev/null || (fail "curl command is not available." && exit 1) +#shellcheck disable=SC2043 +for cmd in curl; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done # Check that all required variables are present. [ -z "${DREVOPS_ACQUIA_KEY}" ] && fail "Missing value for DREVOPS_ACQUIA_KEY." && exit 1 diff --git a/scripts/drevops/task-copy-files-acquia.sh b/scripts/drevops/task-copy-files-acquia.sh index 55c42994e..006ee6c32 100755 --- a/scripts/drevops/task-copy-files-acquia.sh +++ b/scripts/drevops/task-copy-files-acquia.sh @@ -49,6 +49,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +# Pre-flight checks. +for cmd in php curl; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + info "Started database copying between environments in Acquia." # @@ -67,9 +73,6 @@ extract_json_value() { php -r "\$data=json_decode(file_get_contents('php://stdin'), TRUE); isset(\$data[\"${key}\"]) ? print trim(json_encode(\$data[\"${key}\"], JSON_UNESCAPED_SLASHES), '\"') : exit(1);" } -# Pre-flight checks. -command -v curl >/dev/null || (fail "curl command is not available." && exit 1) - # Check that all required variables are present. [ -z "${DREVOPS_ACQUIA_KEY}" ] && fail "Missing value for DREVOPS_ACQUIA_KEY." && exit 1 [ -z "${DREVOPS_ACQUIA_SECRET}" ] && fail "Missing value for DREVOPS_ACQUIA_SECRET." && exit 1 diff --git a/scripts/drevops/task-custom-lagoon.sh b/scripts/drevops/task-custom-lagoon.sh index 966c08e25..2bd3dd7ae 100755 --- a/scripts/drevops/task-custom-lagoon.sh +++ b/scripts/drevops/task-custom-lagoon.sh @@ -86,6 +86,11 @@ if ! command -v lagoon >/dev/null || [ -n "${DREVOPS_LAGOONCLI_FORCE_INSTALL}" ] export PATH="${PATH}:${DREVOPS_LAGOONCLI_PATH}" fi +for cmd in curl lagoon; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + note "Configuring Lagoon instance." #shellcheck disable=SC2218 lagoon config add --force -l "${DREVOPS_TASK_LAGOON_INSTANCE}" -g "${DREVOPS_TASK_LAGOON_INSTANCE_GRAPHQL}" -H "${DREVOPS_TASK_LAGOON_INSTANCE_HOSTNAME}" -P "${DREVOPS_TASK_LAGOON_INSTANCE_PORT}" diff --git a/scripts/drevops/task-purge-cache-acquia.sh b/scripts/drevops/task-purge-cache-acquia.sh index 3a1428c03..a7e528f95 100755 --- a/scripts/drevops/task-purge-cache-acquia.sh +++ b/scripts/drevops/task-purge-cache-acquia.sh @@ -49,6 +49,12 @@ pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } # @formatter:on +# Pre-flight checks. +for cmd in php curl; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + info "Started cache purging in Acquia." # @@ -67,9 +73,6 @@ extract_json_value() { php -r "\$data=json_decode(file_get_contents('php://stdin'), TRUE); isset(\$data[\"${key}\"]) ? print trim(json_encode(\$data[\"${key}\"], JSON_UNESCAPED_SLASHES), '\"') : exit(1);" } -# Pre-flight checks. -command -v curl >/dev/null || (fail "curl command is not available." && exit 1) - # Check that all required variables are present. [ -z "${DREVOPS_ACQUIA_KEY}" ] && fail "Missing value for DREVOPS_ACQUIA_KEY." && exit 1 [ -z "${DREVOPS_ACQUIA_SECRET}" ] && fail "Missing value for DREVOPS_ACQUIA_SECRET." && exit 1 diff --git a/scripts/drevops/update-scaffold.sh b/scripts/drevops/update-scaffold.sh index 014433100..0f220de0f 100755 --- a/scripts/drevops/update-scaffold.sh +++ b/scripts/drevops/update-scaffold.sh @@ -24,6 +24,11 @@ DREVOPS_INSTALLER_URL="${DREVOPS_INSTALLER_URL:-https://install.drevops.com}" export DREVOPS_INSTALLER_URL export DREVOPS_INSTALL_COMMIT +for cmd in php curl; do command -v ${cmd} >/dev/null || { + fail "Command ${cmd} is not available" + exit 1 +}; done + curl -L "${DREVOPS_INSTALLER_URL}"?"$(date +%s)" >/tmp/install php /tmp/install --quiet rm /tmp/install >/dev/null