Skip to content

Instantly share code, notes, and snippets.

@qrkourier
Last active June 12, 2024 22:22
Show Gist options
  • Save qrkourier/f6bbd798ab500a3169d7df7addd62971 to your computer and use it in GitHub Desktop.
Save qrkourier/f6bbd798ab500a3169d7df7addd62971 to your computer and use it in GitHub Desktop.
install a specific version of the ziti-edge-tunnel Linux binary from GitHub
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
get(){
local target=$1
local arch=$2
cd $(mktemp -d)
wget https://github.com/openziti/ziti-tunnel-sdk-c/releases/download/${target}/ziti-edge-tunnel-Linux_${arch}.zip
unzip ./ziti-edge-tunnel-Linux_x86_64.zip
install ./ziti-edge-tunnel /opt/openziti/bin/
}
if ! (( $# ))
then
echo "ERROR: give target version (e.g., 'getzet.bash v1.0.0 [x86_64|arm|arm64]')" >&2
exit 1
fi
VERSION_TARGET=$1
ARCH_TARGET=${2:-x86_64}
if [[ -x /opt/openziti/bin/ziti-edge-tunnel ]]
then
VERSION_CURRENT=$(/opt/openziti/bin/ziti-edge-tunnel version)
if [[ "${VERSION_CURRENT}" == "${VERSION_TARGET}" ]]
then
exit 0
elif [[ -n "${VERSION_CURRENT}" ]]
then
mv /opt/openziti/bin/ziti-edge-tunnel{,-${VERSION_CURRENT}}
fi
fi
if [[ -s /opt/openziti/bin/ziti-edge-tunnel-${VERSION_TARGET} ]]
then
mv /opt/openziti/bin/ziti-edge-tunnel{-${VERSION_TARGET},}
else
get "${VERSION_TARGET}" "${ARCH_TARGET}"
fi
systemctl restart ziti-edge-tunnel.service
journalctl -lfu ziti-edge-tunnel.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment