Skip to content

feat: bundle a local version of install.sh #16064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
allow setting a custom origin, just in case
  • Loading branch information
aslilac committed Jan 13, 2025
commit a25502f6c4eb1125d66b290ed454f1f90d440e38
26 changes: 16 additions & 10 deletions site/static/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ main() {

unset \
DRY_RUN \
OPTIONAL \
ORIGIN \
ALL_FLAGS \
RSH_ARGS \
RSH

ORIGIN="{{ .Origin }}"
ALL_FLAGS=""

while [ "$#" -gt 0 ]; do
Expand All @@ -139,6 +140,13 @@ main() {
--dry-run)
DRY_RUN=1
;;
--origin)
ORIGIN="$(parse_arg "$@")"
shift
;;
--origin=*)
ORIGIN="$(parse_arg "$@")"
;;
--prefix)
STANDALONE_INSTALL_PREFIX="$(parse_arg "$@")"
shift
Expand Down Expand Up @@ -188,7 +196,7 @@ main() {
if [ "${RSH_ARGS-}" ]; then
RSH="${RSH-ssh}"
echoh "Installing remotely with $RSH $RSH_ARGS"
curl -fsSL "{{ .Origin }}/install.sh" | prefix "$RSH_ARGS" "$RSH" "$RSH_ARGS" sh -s -- "$ALL_FLAGS"
curl -fsSL "$ORIGIN/install.sh" | prefix "$RSH_ARGS" "$RSH" "$RSH_ARGS" sh -s -- "$ALL_FLAGS"
return
fi

Expand Down Expand Up @@ -223,7 +231,7 @@ parse_arg() {
opt="${1%%=*}"
# Remove everything before first equal sign.
optarg="${1#*=}"
if [ ! "$optarg" ] && [ ! "${OPTIONAL-}" ]; then
if [ ! "$optarg" ]; then
echoerr "$opt requires an argument"
echoerr "Run with --help to see usage."
exit 1
Expand All @@ -235,11 +243,9 @@ parse_arg() {

case "${2-}" in
"" | -*)
if [ ! "${OPTIONAL-}" ]; then
echoerr "$1 requires an argument"
echoerr "Run with --help to see usage."
exit 1
fi
echoerr "$1 requires an argument"
echoerr "Run with --help to see usage."
exit 1
;;
*)
echo "$2"
Expand Down Expand Up @@ -267,12 +273,12 @@ fetch() {
}

install_standalone() {
echoh "Installing coder-$OS-$ARCH {{ .Version }} from {{ .Origin }}."
echoh "Installing coder-$OS-$ARCH {{ .Version }} from $ORIGIN."
echoh

BINARY_FILE="$CACHE_DIR/coder-${OS}-${ARCH}-{{ .Version }}"

fetch "{{ .Origin }}/bin/coder-${OS}-${ARCH}" "$BINARY_FILE"
fetch "$ORIGIN/bin/coder-${OS}-${ARCH}" "$BINARY_FILE"

# -w only works if the directory exists so try creating it first. If this
# fails we can ignore the error as the -w check will then swap us to sudo.
Expand Down
Loading