diff --git a/_home.macos/private_dot_config/sz.env/zzz_teleport.env b/_home.macos/private_dot_config/sz.env/zzz_teleport.env new file mode 120000 index 0000000..429b263 --- /dev/null +++ b/_home.macos/private_dot_config/sz.env/zzz_teleport.env @@ -0,0 +1 @@ +../../../_src.posix/private_dot_config/sz.env/zzz_teleport.env \ No newline at end of file diff --git a/_home.macos/private_dot_local/bin/executable_vast-teleport b/_home.macos/private_dot_local/bin/executable_vast-teleport new file mode 100644 index 0000000..df3e6ac --- /dev/null +++ b/_home.macos/private_dot_local/bin/executable_vast-teleport @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +# Usage: ./vast-teleport get version [auto|major|] +# Example: ./latest_teleport_version.sh get major + +set -e + +SCRIPT_NAME="${0##/*}" +usage() { + printf '%s\n' \ + "${SCRIPT_NAME} command..." \ + '' \ + 'Usage:' \ + ' get version same as running `tsh version`' \ + ' get version server grabs the version of the server' \ + ' get version server major grabs the major version of the server' \ + ' get version client 15 grabs the latest version of the client for major' \ + " get version client auto grab the latest version based on the server's major version" \ + '' \ + " To update teleport's \`tsh\` with \`chezmoi\` run the following" \ + ' eval "$(vast-teleport get version server major -) czx status"' \ + '' + exit 2 +} + +get_server_version() { + curl -s https://teleport.vastdata.com:3080/webapi/ping \ + | jq -r '.server_version' +} +get_server_major() { + get_server_version | awk -F. '{print $1}' +} + +get_latest_version_by_major() { + local MAJOR="$1" + curl -s "https://api.github.com/repos/gravitational/teleport/releases?per_page=100" \ + | jq -r ".[].tag_name" \ + | grep -E "^v${MAJOR}\." \ + | sort -V \ + | tail -n 1 +} + +case "$1" in + get) shift; case $1 in + version) shift; case $1 in + '') tsh version ;; + server) shift; case $1 in + '') get_server_version ;; + major) shift; case $1 in + '') get_server_major ;; + '-') printf 'TELEPORT_MAJOR=' && get_server_major ;; + *) usage ;; + esac;; + *) usage ;; + esac ;; + client) shift; case $1 in + '') usage ;; + auto) get_latest_version_by_major "$(get_server_major)" ;; + *) get_latest_version_by_major "${@}" ;; + esac;; + *) usage ;; + esac;; + *) usage ;; + esac ;; + *) usage ;; +esac +# MAJOR="$1" +# +# if [[ -z "$MAJOR" ]]; then +# echo "Usage: $0 " +# exit 1 +# fi +# +# curl -s "https://api.github.com/repos/gravitational/teleport/releases?per_page=100" | \ +# jq -r ".[].tag_name" | \ +# grep -E "^v${MAJOR}\." | \ +# sort -V | \ +# tail -n 1 diff --git a/_src.posix/private_dot_config/sz.env/zzz_teleport.env b/_src.posix/private_dot_config/sz.env/zzz_teleport.env new file mode 100644 index 0000000..28f8a6d --- /dev/null +++ b/_src.posix/private_dot_config/sz.env/zzz_teleport.env @@ -0,0 +1,11 @@ +#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"' + +BASE_SHELL=${BASE_SHELL:-${SHELL##*/}} + +if is_cmd tsh && tsh version | grep -q '^Teleport'; then + tsh-login() { + command tsh login --proxy=teleport.vastdata.com "${@}" + } + + . <(tsh --completion-script-${BASE_SHELL}) +fi