From 339acb9a8a0c5d13888fbf19f1aa7556a9920b32 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 3 Apr 2024 16:48:57 +0300 Subject: [PATCH 1/3] feat(install.sh): add support for `--mainline` (default) and `--stable` --- install.sh | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/install.sh b/install.sh index 0cd1344413dcd..e1da558b18ec1 100755 --- a/install.sh +++ b/install.sh @@ -26,18 +26,21 @@ The remote host must have internet access. ${not_curl_usage-} Usage: - $arg0 [--dry-run] [--version X.X.X] [--edge] [--method detect] \ + ${arg0} [--dry-run] [--mainline | --stable | --version X.X.X] [--method detect] \ [--prefix ~/.local] [--rsh ssh] [user@host] --dry-run Echo the commands for the install process without running them. + --mainline + Install the latest mainline version (default). + + --stable + Install the latest stable version instead of the latest mainline version. + --version X.X.X Install a specific version instead of the latest. - --edge - Install the latest edge version instead of the latest stable version. - --method [detect | standalone] Choose the installation method. Defaults to detect. - detect detects the system package manager and tries to use it. @@ -89,15 +92,26 @@ EOF } echo_latest_version() { - if [ "${EDGE-}" ]; then - version="$(curl -fsSL https://api.github.com/repos/coder/coder/releases | awk 'match($0,/.*"html_url": "(.*\/releases\/tag\/.*)".*/)' | head -n 1 | awk -F '"' '{print $4}')" - else + if [ "${MAINLINE}" = 0 ]; then # https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-2758860 version="$(curl -fsSLI -o /dev/null -w "%{url_effective}" https://github.com/coder/coder/releases/latest)" - fi - version="${version#https://github.com/coder/coder/releases/tag/}" - version="${version#v}" - echo "$version" + version="${version#https://github.com/coder/coder/releases/tag/v}" + else + # Fetch the releases from the GitHub API, sort by version number, + # and take the first result. Note that we're sorting by space- + # separated numbers and without utilizing the sort -V flag for the + # best compatibility. + version="$( + curl -fsSL https://api.github.com/repos/coder/coder/releases | + awk -F'"' '/"tag_name"/ {print $4}' | + tr -d v | + tr . ' ' | + sort -k1,1nr -k2,2nr -k3,3nr | + head -n1 | + tr ' ' . + )" + fi + echo "${version}" } echo_standalone_postinstall() { @@ -224,6 +238,7 @@ EOF } main() { + MAINLINE=1 TERRAFORM_VERSION="1.6.6" if [ "${TRACE-}" ]; then @@ -236,7 +251,6 @@ main() { OPTIONAL \ ALL_FLAGS \ RSH_ARGS \ - EDGE \ RSH \ WITH_TERRAFORM \ CAP_NET_ADMIN @@ -282,8 +296,12 @@ main() { --version=*) VERSION="$(parse_arg "$@")" ;; - --edge) - EDGE=1 + # Support edge for backwards compatibility. + --mainline | --edge) + MAINLINE=1 + ;; + --stable) + MAINLINE=0 ;; --rsh) RSH="$(parse_arg "$@")" From ace59dfaa148800de7c77e163409a1243378f0c8 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 3 Apr 2024 17:38:40 +0300 Subject: [PATCH 2/3] add advisory message --- install.sh | 65 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/install.sh b/install.sh index e1da558b18ec1..d2e6c9cb08bb9 100755 --- a/install.sh +++ b/install.sh @@ -91,38 +91,45 @@ The installer will cache all downloaded assets into ~/.cache/coder EOF } -echo_latest_version() { - if [ "${MAINLINE}" = 0 ]; then - # https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-2758860 - version="$(curl -fsSLI -o /dev/null -w "%{url_effective}" https://github.com/coder/coder/releases/latest)" - version="${version#https://github.com/coder/coder/releases/tag/v}" - else - # Fetch the releases from the GitHub API, sort by version number, - # and take the first result. Note that we're sorting by space- - # separated numbers and without utilizing the sort -V flag for the - # best compatibility. - version="$( - curl -fsSL https://api.github.com/repos/coder/coder/releases | - awk -F'"' '/"tag_name"/ {print $4}' | - tr -d v | - tr . ' ' | - sort -k1,1nr -k2,2nr -k3,3nr | - head -n1 | - tr ' ' . - )" - fi +echo_latest_stable_version() { + # https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-2758860 + version="$(curl -fsSLI -o /dev/null -w "%{url_effective}" https://github.com/coder/coder/releases/latest)" + version="${version#https://github.com/coder/coder/releases/tag/v}" echo "${version}" } +echo_latest_mainline_version() { + # Fetch the releases from the GitHub API, sort by version number, + # and take the first result. Note that we're sorting by space- + # separated numbers and without utilizing the sort -V flag for the + # best compatibility. + curl -fsSL https://api.github.com/repos/coder/coder/releases | + awk -F'"' '/"tag_name"/ {print $4}' | + tr -d v | + tr . ' ' | + sort -k1,1nr -k2,2nr -k3,3nr | + head -n1 | + tr ' ' . +} + echo_standalone_postinstall() { if [ "${DRY_RUN-}" ]; then echo_dryrun_postinstall return fi + channel=mainline + advisory="To install our stable release (v${STABLE_VERSION}), use the --stable flag. " + if [ "${MAINLINE}" = 0 ]; then + channel=stable + advisory="" + fi + cath < Date: Wed, 3 Apr 2024 18:45:22 +0300 Subject: [PATCH 3/3] s/backwards/backward/ --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index d2e6c9cb08bb9..3df67fa789e6a 100755 --- a/install.sh +++ b/install.sh @@ -303,7 +303,7 @@ main() { --version=*) VERSION="$(parse_arg "$@")" ;; - # Support edge for backwards compatibility. + # Support edge for backward compatibility. --mainline | --edge) MAINLINE=1 ;;