From 6f935e845922f52680a5c7b4277dbeecd411da5e Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sat, 15 Apr 2023 17:38:24 -0400 Subject: [PATCH 1/5] add tar to required command list --- quickstart/docker/image/ziti-cli-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 1520ba7bd..4f6a54c81 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -276,7 +276,7 @@ function getZiti { } function checkPrereqs { - commands_to_test=(curl jq) + commands_to_test=(curl jq tar) missing_requirements="" # verify all the commands required in the automation exist before trying to run the full suite for cmd in "${commands_to_test[@]}" From adddf168ade846b1bf1e0c9c8eefd089b40fcac6 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sat, 15 Apr 2023 17:56:32 -0400 Subject: [PATCH 2/5] add hostname too --- quickstart/docker/image/ziti-cli-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 4f6a54c81..09a1a4178 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -276,7 +276,7 @@ function getZiti { } function checkPrereqs { - commands_to_test=(curl jq tar) + commands_to_test=(curl jq tar hostname) missing_requirements="" # verify all the commands required in the automation exist before trying to run the full suite for cmd in "${commands_to_test[@]}" From b96829920dfc7f45f4bb33bce678832820d092e3 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sat, 15 Apr 2023 17:58:39 -0400 Subject: [PATCH 3/5] see if this will add a newline like i expected to see --- quickstart/docker/image/ziti-cli-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 09a1a4178..091b194f8 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -283,7 +283,7 @@ function checkPrereqs { do # checking all commands are on the path before continuing... if ! [[ -x "$(command -v "${cmd}")" ]]; then - missing_requirements="${missing_requirements} * ${cmd}" + missing_requirements="${missing_requirements} * ${cmd}\n" fi done # are requirements ? if yes, stop here and help 'em out From 018a9b30579e5455e034bb76f0f1975190b7691e Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sat, 15 Apr 2023 18:21:10 -0400 Subject: [PATCH 4/5] trying literal newline --- quickstart/docker/image/ziti-cli-functions.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 091b194f8..9a55daacc 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -283,7 +283,8 @@ function checkPrereqs { do # checking all commands are on the path before continuing... if ! [[ -x "$(command -v "${cmd}")" ]]; then - missing_requirements="${missing_requirements} * ${cmd}\n" + missing_requirements="${missing_requirements} * ${cmd} +" fi done # are requirements ? if yes, stop here and help 'em out From 5e2c044adf267e5f9c828979e7eae037ba2503cb Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Mon, 17 Apr 2023 08:05:45 -0400 Subject: [PATCH 5/5] rearrange where checkPrereqs is defined and call it when sourcing to make sure all the functions are found --- quickstart/docker/image/ziti-cli-functions.sh | 66 +++++++++---------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 9a55daacc..7b1d1b89c 100755 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -2,14 +2,6 @@ set -uo pipefail -# the default ZITI_NETWORK (network name) is the short hostname -: "${DEFAULT_ZITI_NETWORK:="$(hostname -s)"}" - -# shellcheck disable=SC2155 -export DEFAULT_ZITI_HOME_LOCATION="${HOME}/.ziti/quickstart/${DEFAULT_ZITI_NETWORK}" - -export ZITI_QUICKSTART_ENVROOT="${HOME}/.ziti/quickstart" - ASCI_WHITE='\033[01;37m' ASCI_RESTORE='\033[0m' ASCI_RED='\033[00;31m' @@ -44,6 +36,38 @@ function BLUE { echo "${ASCI_BLUE}${1-}${ASCI_RESTORE}" } +function checkPrereqs { + commands_to_test=(curl jq tar hostname) + missing_requirements="" + # verify all the commands required in the automation exist before trying to run the full suite + for cmd in "${commands_to_test[@]}" + do + # checking all commands are on the path before continuing... + if ! [[ -x "$(command -v "${cmd}")" ]]; then + missing_requirements="${missing_requirements} * ${cmd} +" + fi + done + # are requirements ? if yes, stop here and help 'em out + if ! [[ "" = "${missing_requirements}" ]]; then + echo " " + echo "You're missing one or more commands that are used in this script." + echo "Please ensure the commands listed are on the path and then try again." + echo "${missing_requirements}" + echo " " + return 1 + fi +} + +checkPrereqs + +# the default ZITI_NETWORK (network name) is the short hostname +: "${DEFAULT_ZITI_NETWORK:="$(hostname -s)"}" + +# shellcheck disable=SC2155 +export DEFAULT_ZITI_HOME_LOCATION="${HOME}/.ziti/quickstart/${DEFAULT_ZITI_NETWORK}" +export ZITI_QUICKSTART_ENVROOT="${HOME}/.ziti/quickstart" + function zitiLogin { "${ZITI_BIN_DIR-}/ziti" edge login "${ZITI_EDGE_CTRL_ADVERTISED}" -u "${ZITI_USER-}" -p "${ZITI_PWD}" -c "${ZITI_PKI_OS_SPECIFIC}/${ZITI_EDGE_CONTROLLER_ROOTCA_NAME}/certs/${ZITI_EDGE_CONTROLLER_INTERMEDIATE_NAME}.cert" } @@ -275,32 +299,6 @@ function getZiti { fi } -function checkPrereqs { - commands_to_test=(curl jq tar hostname) - missing_requirements="" - # verify all the commands required in the automation exist before trying to run the full suite - for cmd in "${commands_to_test[@]}" - do - # checking all commands are on the path before continuing... - if ! [[ -x "$(command -v "${cmd}")" ]]; then - missing_requirements="${missing_requirements} * ${cmd} -" - fi - done - # are requirements ? if yes, stop here and help 'em out - if ! [[ "" = "${missing_requirements}" ]]; then - echo " " - echo "You're missing one or more commands that are used in this script." - echo "Please ensure the commands listed are on the path and then try again." - echo "${missing_requirements}" - echo " " - echo " " - return 1 - else - echo -e "$(GREEN "Prerequisites confirmed")" - fi -} - function _portCheck { if [[ "${1-}" == "" ]] || [[ "${2-}" == "" ]]; then echo -e "_portCheck Usage: _portCheck "