From d854d0abd87639aa5e07506de2a5faa940c27ecc Mon Sep 17 00:00:00 2001 From: gberl002 Date: Fri, 18 Mar 2022 14:47:25 -0400 Subject: [PATCH 1/7] Adding warning for M1 macs and pulling AMD instead. --- quickstart/docker/image/ziti-cli-functions.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index cd6f027a4..f05b6de18 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -135,8 +135,10 @@ function getLatestZitiVersion { fi ZITI_ARCH="amd64" - if [[ "$(uname -a)" == *"arm"* ]]; then + if [[ "$(uname -a)" == *"arm"* ]] && [[ "${ZITI_OSTYPE}" != "darwin" ]]; then ZITI_ARCH="arm" + else + echo -e "$(YELLOW "WARN: It has been detected that you are using an Apple computer with ARM architecture. Deployment of Apple ARM architecture distributions is currently unsupported through git, the installer will pull darwin amd distribution instead.")" fi unset ZITI_BINARIES_VERSION From e7aa63c0a734d1df89a1445202ca42bf3c29988b Mon Sep 17 00:00:00 2001 From: gberl002 Date: Fri, 18 Mar 2022 16:06:00 -0400 Subject: [PATCH 2/7] Adding ability to override the ziti version used in express install --- quickstart/docker/image/ziti-cli-functions.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index f05b6de18..dcd29cc77 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -127,13 +127,16 @@ function checkHostsFile { fi } -function getLatestZitiVersion { +function getZitiVersion { setupZitiHome if ! setOs; then return 1 fi + # If not overridden, get latest ziti version + if [[ "${ZITI_VERSION_OVERRIDE-}" == "" ]]; then export ZITI_VERSION_OVERRIDE="latest"; fi + ZITI_ARCH="amd64" if [[ "$(uname -a)" == *"arm"* ]] && [[ "${ZITI_OSTYPE}" != "darwin" ]]; then ZITI_ARCH="arm" @@ -144,16 +147,16 @@ function getLatestZitiVersion { unset ZITI_BINARIES_VERSION if [[ "${ZITI_BINARIES_VERSION-}" == "" ]]; then - zitilatest=$(curl -s https://api.github.com/repos/openziti/ziti/releases/latest) + ziticurl="$(curl -s https://api.github.com/repos/openziti/ziti/releases/tags/${ZITI_VERSION_OVERRIDE})" # shellcheck disable=SC2155 - export ZITI_BINARIES_FILE=$(echo "${zitilatest}" | tr '\r\n' ' ' | jq -r '.assets[] | select(.name | startswith("'"ziti-${ZITI_OSTYPE}-${ZITI_ARCH}"'")) | .name') + export ZITI_BINARIES_FILE=$(echo "${ziticurl}" | tr '\r\n' ' ' | jq -r '.assets[] | select(.name | startswith("'"ziti-${ZITI_OSTYPE}-${ZITI_ARCH}"'")) | .name') # shellcheck disable=SC2155 - export ZITI_BINARIES_VERSION=$(echo "${zitilatest}" | tr '\r\n' ' ' | jq -r '.tag_name') + export ZITI_BINARIES_VERSION=$(echo "${ziticurl}" | tr '\r\n' ' ' | jq -r '.tag_name') fi echo "ZITI_BINARIES_VERSION: ${ZITI_BINARIES_VERSION}" } -function getLatestZiti { +function getZiti { setupZitiHome checkEnvVariable ZITI_HOME retVal=$? @@ -169,7 +172,7 @@ function getLatestZiti { mkdir -p "${ziti_bin_root}" - if ! getLatestZitiVersion; then + if ! getZitiVersion; then return 1 fi @@ -386,8 +389,8 @@ function ziti_expressConfiguration { setupZitiHome echo -e "ZITI HOME SET TO: $(BLUE "${ZITI_HOME}")" - if ! getLatestZiti "no"; then - echo -e "$(RED "getLatestZiti failed")" + if ! getZiti "no"; then + echo -e "$(RED "getZiti failed")" return 1 fi if ! generateEnvFile; then From bcac9490cfdca5100f2f75fb2a6b77ee5896648d Mon Sep 17 00:00:00 2001 From: gberl002 Date: Mon, 21 Mar 2022 14:28:03 -0400 Subject: [PATCH 3/7] Added some error handling and fixed pulling latest --- quickstart/docker/image/ziti-cli-functions.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index dcd29cc77..e63ea10ad 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -134,9 +134,6 @@ function getZitiVersion { return 1 fi - # If not overridden, get latest ziti version - if [[ "${ZITI_VERSION_OVERRIDE-}" == "" ]]; then export ZITI_VERSION_OVERRIDE="latest"; fi - ZITI_ARCH="amd64" if [[ "$(uname -a)" == *"arm"* ]] && [[ "${ZITI_OSTYPE}" != "darwin" ]]; then ZITI_ARCH="arm" @@ -147,12 +144,23 @@ function getZitiVersion { unset ZITI_BINARIES_VERSION if [[ "${ZITI_BINARIES_VERSION-}" == "" ]]; then - ziticurl="$(curl -s https://api.github.com/repos/openziti/ziti/releases/tags/${ZITI_VERSION_OVERRIDE})" + if [[ "${ZITI_VERSION_OVERRIDE-}" == "" ]] || [[ "${ZITI_VERSION_OVERRIDE-}" == "latest" ]]; then + export ZITI_VERSION_OVERRIDE="latest" + ziticurl="$(curl -s https://api.github.com/repos/openziti/ziti/releases/latest)" + echo -e "using latest" + else + ziticurl="$(curl -s https://api.github.com/repos/openziti/ziti/releases/tags/${ZITI_VERSION_OVERRIDE})" + echo -e "using ${ZITI_VERSION_OVERRIDE}" + fi # shellcheck disable=SC2155 export ZITI_BINARIES_FILE=$(echo "${ziticurl}" | tr '\r\n' ' ' | jq -r '.assets[] | select(.name | startswith("'"ziti-${ZITI_OSTYPE}-${ZITI_ARCH}"'")) | .name') # shellcheck disable=SC2155 export ZITI_BINARIES_VERSION=$(echo "${ziticurl}" | tr '\r\n' ' ' | jq -r '.tag_name') fi + if [[ "${ZITI_BINARIES_VERSION}" == "null" ]]; then + echo -e " * $(RED "ERROR: This version of ziti (${ZITI_VERSION_OVERRIDE}) could not be found. Please check the version and try again.") " + return 1 + fi echo "ZITI_BINARIES_VERSION: ${ZITI_BINARIES_VERSION}" } From b8d09ed5d881c46d09bc57b690142bf1ada33b65 Mon Sep 17 00:00:00 2001 From: gberl002 Date: Tue, 22 Mar 2022 12:48:22 -0400 Subject: [PATCH 4/7] Removing some print statements left in --- quickstart/docker/image/ziti-cli-functions.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index e63ea10ad..6e490f174 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -147,10 +147,8 @@ function getZitiVersion { if [[ "${ZITI_VERSION_OVERRIDE-}" == "" ]] || [[ "${ZITI_VERSION_OVERRIDE-}" == "latest" ]]; then export ZITI_VERSION_OVERRIDE="latest" ziticurl="$(curl -s https://api.github.com/repos/openziti/ziti/releases/latest)" - echo -e "using latest" else ziticurl="$(curl -s https://api.github.com/repos/openziti/ziti/releases/tags/${ZITI_VERSION_OVERRIDE})" - echo -e "using ${ZITI_VERSION_OVERRIDE}" fi # shellcheck disable=SC2155 export ZITI_BINARIES_FILE=$(echo "${ziticurl}" | tr '\r\n' ' ' | jq -r '.assets[] | select(.name | startswith("'"ziti-${ZITI_OSTYPE}-${ZITI_ARCH}"'")) | .name') From ae91f4f17b9fc1be61d3383f5348150acf6e124a Mon Sep 17 00:00:00 2001 From: gberl002 Date: Tue, 22 Mar 2022 16:50:50 -0400 Subject: [PATCH 5/7] Separating the get version method for custom versions. Added some more error handling. --- quickstart/docker/image/ziti-cli-functions.sh | 90 +++++++++++++++---- 1 file changed, 75 insertions(+), 15 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index 6e490f174..feec8db8b 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -127,7 +127,37 @@ function checkHostsFile { fi } -function getZitiVersion { +function verifyZitiVersionExists { + setupZitiHome + + if ! setOs; then + return 1 + fi + + ZITI_ARCH="amd64" + if [[ "$(uname -a)" == *"arm"* ]] && [[ "${ZITI_OSTYPE}" != "darwin" ]]; then + ZITI_ARCH="arm" + else + echo -e "$(YELLOW "WARN: It has been detected that you are using an Apple computer with ARM architecture. Deployment of Apple ARM architecture distributions is currently unsupported through git, the installer will pull darwin amd distribution instead.")" + fi + + unset ZITI_BINARIES_VERSION + + ziticurl="$(curl -s https://api.github.com/repos/openziti/ziti/releases/tags/"${ZITI_VERSION_OVERRIDE}")" + # shellcheck disable=SC2155 + export ZITI_BINARIES_FILE=$(echo "${ziticurl}" | tr '\r\n' ' ' | jq -r '.assets[] | select(.name | startswith("'"ziti-${ZITI_OSTYPE}-${ZITI_ARCH}"'")) | .name') + # shellcheck disable=SC2155 + export ZITI_BINARIES_VERSION=$(echo "${ziticurl}" | tr '\r\n' ' ' | jq -r '.tag_name') + + # Check if there was an error while trying to get the requested version + if [[ "${ZITI_BINARIES_VERSION-}" == "null" ]]; then + return 1 + fi + + echo "ZITI_BINARIES_VERSION: ${ZITI_BINARIES_VERSION}" +} + +function getLatestZitiVersion { setupZitiHome if ! setOs; then @@ -144,20 +174,11 @@ function getZitiVersion { unset ZITI_BINARIES_VERSION if [[ "${ZITI_BINARIES_VERSION-}" == "" ]]; then - if [[ "${ZITI_VERSION_OVERRIDE-}" == "" ]] || [[ "${ZITI_VERSION_OVERRIDE-}" == "latest" ]]; then - export ZITI_VERSION_OVERRIDE="latest" - ziticurl="$(curl -s https://api.github.com/repos/openziti/ziti/releases/latest)" - else - ziticurl="$(curl -s https://api.github.com/repos/openziti/ziti/releases/tags/${ZITI_VERSION_OVERRIDE})" - fi + zitilatest=$(curl -s https://api.github.com/repos/openziti/ziti/releases/latest) # shellcheck disable=SC2155 - export ZITI_BINARIES_FILE=$(echo "${ziticurl}" | tr '\r\n' ' ' | jq -r '.assets[] | select(.name | startswith("'"ziti-${ZITI_OSTYPE}-${ZITI_ARCH}"'")) | .name') + export ZITI_BINARIES_FILE=$(echo "${zitilatest}" | tr '\r\n' ' ' | jq -r '.assets[] | select(.name | startswith("'"ziti-${ZITI_OSTYPE}-${ZITI_ARCH}"'")) | .name') # shellcheck disable=SC2155 - export ZITI_BINARIES_VERSION=$(echo "${ziticurl}" | tr '\r\n' ' ' | jq -r '.tag_name') - fi - if [[ "${ZITI_BINARIES_VERSION}" == "null" ]]; then - echo -e " * $(RED "ERROR: This version of ziti (${ZITI_VERSION_OVERRIDE}) could not be found. Please check the version and try again.") " - return 1 + export ZITI_BINARIES_VERSION=$(echo "${zitilatest}" | tr '\r\n' ' ' | jq -r '.tag_name') fi echo "ZITI_BINARIES_VERSION: ${ZITI_BINARIES_VERSION}" } @@ -178,8 +199,17 @@ function getZiti { mkdir -p "${ziti_bin_root}" - if ! getZitiVersion; then - return 1 + # Get the latest version unless a specific version is specified + if [[ "${ZITI_VERSION_OVERRIDE-}" == "" ]]; then + if ! getLatestZitiVersion; then + return 1 + fi + else + # Check if an error occurred while trying to pull desired version (happens with incorrect version or formatting issue) + if ! verifyZitiVersionExists; then + echo -e " * $(RED "ERROR: This version of ziti (${ZITI_VERSION_OVERRIDE}) could not be found. Please check the version and try again. The version should follow the format \"vx.x.x\".") " + return 1 + fi fi if [[ "${ZITI_BIN_DIR-}" == "" ]]; then export ZITI_BIN_DIR="${ziti_bin_root}/ziti-${ZITI_BINARIES_VERSION}"; else echo "Using ZITI_BIN_DIR: ${ZITI_BIN_DIR}"; fi @@ -353,7 +383,37 @@ function ziti_expressConfiguration { echo " " if [[ "${REPLY}" == [Yy]* ]]; then echo -e "$(GREEN "Clearing existing Ziti variables and continuing with express install")" + + # Check if the user chose a specific version + specifiedVersion="" + if [[ "${ZITI_VERSION_OVERRIDE-}" != "" ]] && [[ "${ZITI_VERSION_OVERRIDE-}" != "${ZITI_BINARIES_VERSION-}" ]]; then + # Don't allow overriding the version if ziti quickstart was already run, the DB may not be compatible + echo -e "$(RED " --- Overriding the ziti version is not supported if the version differs from one already installed. ---")" + echo -en "Would you like to continue by using the latest version. (y/N)?" + read -r + echo " " + if [[ "${REPLY}" == [Yy]* ]]; then + unset ZITI_VERSION_OVERRIDE + else + return 1 + fi + elif [[ "${ZITI_VERSION_OVERRIDE-}" != "" ]]; then + echo -e "$(RED " --- You have set the ZITI_VERSION_OVERRIDE value to ${ZITI_VERSION_OVERRIDE}. ---")" + echo -en "Would you like to use this version again, choosing no will pull the latest version. (y/N)?" + read -r + echo " " + if [[ "${REPLY}" == [Yy]* ]]; then + specifiedVersion="${ZITI_VERSION_OVERRIDE}" + fi + fi + + # Silently clear ziti variables unsetZitiEnv "-s" + + if [[ "${specifiedVersion}" != "" ]]; then + export ZITI_VERSION_OVERRIDE="${specifiedVersion}" + fi + # Stop any devices currently running to avoid port collisions stopAllEdgeRouters stopZitiController From a9d7623674caba5a30a80e1adf601e05e8bdfe02 Mon Sep 17 00:00:00 2001 From: gberl002 Date: Wed, 23 Mar 2022 09:20:33 -0400 Subject: [PATCH 6/7] Fixing bug with M1 support logic --- quickstart/docker/image/ziti-cli-functions.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/quickstart/docker/image/ziti-cli-functions.sh b/quickstart/docker/image/ziti-cli-functions.sh index feec8db8b..cf805488a 100644 --- a/quickstart/docker/image/ziti-cli-functions.sh +++ b/quickstart/docker/image/ziti-cli-functions.sh @@ -135,10 +135,10 @@ function verifyZitiVersionExists { fi ZITI_ARCH="amd64" - if [[ "$(uname -a)" == *"arm"* ]] && [[ "${ZITI_OSTYPE}" != "darwin" ]]; then - ZITI_ARCH="arm" - else + if [[ "$(uname -a)" == *"arm"* ]] && [[ "${ZITI_OSTYPE}" == "darwin" ]]; then echo -e "$(YELLOW "WARN: It has been detected that you are using an Apple computer with ARM architecture. Deployment of Apple ARM architecture distributions is currently unsupported through git, the installer will pull darwin amd distribution instead.")" + elif [[ "$(uname -a)" == *"arm"* ]]; then + ZITI_ARCH="arm" fi unset ZITI_BINARIES_VERSION @@ -165,10 +165,10 @@ function getLatestZitiVersion { fi ZITI_ARCH="amd64" - if [[ "$(uname -a)" == *"arm"* ]] && [[ "${ZITI_OSTYPE}" != "darwin" ]]; then - ZITI_ARCH="arm" - else + if [[ "$(uname -a)" == *"arm"* ]] && [[ "${ZITI_OSTYPE}" == "darwin" ]]; then echo -e "$(YELLOW "WARN: It has been detected that you are using an Apple computer with ARM architecture. Deployment of Apple ARM architecture distributions is currently unsupported through git, the installer will pull darwin amd distribution instead.")" + elif [[ "$(uname -a)" == *"arm"* ]]; then + ZITI_ARCH="arm" fi unset ZITI_BINARIES_VERSION From ffd9a8ea91b9d8078497ecfee048981319de4610 Mon Sep 17 00:00:00 2001 From: gberl002 Date: Fri, 25 Mar 2022 11:36:45 -0400 Subject: [PATCH 7/7] Updated comment to reflect action field name --- ziti/cmd/ziti/cmd/config_templates/controller.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ziti/cmd/ziti/cmd/config_templates/controller.yml b/ziti/cmd/ziti/cmd/config_templates/controller.yml index 2c1828f06..384e6941a 100644 --- a/ziti/cmd/ziti/cmd/config_templates/controller.yml +++ b/ziti/cmd/ziti/cmd/config_templates/controller.yml @@ -88,14 +88,14 @@ edge: # edgeIdentity - optional # A section for identity enrollment specific settings edgeIdentity: - # durationMinutes - optional, default {{ .Controller.EdgeIdentityDuration.Minutes }}m + # duration - optional, default {{ .Controller.EdgeIdentityDuration.Minutes }}m # The length of time that a Ziti Edge Identity enrollment should remain valid. After # this duration, the enrollment will expire and no longer be usable. duration: {{ .Controller.EdgeIdentityDuration.Minutes }}m # edgeRouter - Optional # A section for edge router enrollment specific settings. edgeRouter: - # durationMinutes - optional, default {{ .Controller.EdgeRouterDuration.Minutes }}m + # duration - optional, default {{ .Controller.EdgeRouterDuration.Minutes }}m # The length of time that a Ziti Edge Router enrollment should remain valid. After # this duration, the enrollment will expire and no longer be usable. duration: {{ .Controller.EdgeRouterDuration.Minutes }}m