Skip to content

feat: one-line install script #1924

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 21 commits into from
Jun 1, 2022
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
add option for binary name
  • Loading branch information
bpmct committed Jun 1, 2022
commit 8cba04c19de6d173f3eee4fe3be605625f4c3437
30 changes: 20 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ Usage:
Sets the prefix used by standalone release archives. Defaults to /usr/local
and the binary is copied into /usr/local/bin
To install in \$HOME, pass ---prefix=\$HOME/.local

--binary-name <name>
Sets the name for the CLI in standalone release archives. Defaults to "coder"
To use the CLI as coder2, pass --binary-name=coder2
Note: in-product documentation will always refer to the CLI as "coder"

--rsh <bin>
Specifies the remote shell for remote installation. Defaults to ssh.
Expand Down Expand Up @@ -79,28 +84,25 @@ echo_latest_version() {
}

echo_standalone_postinstall() {
if [ "$STANDALONE_INSTALL_PREFIX" = /usr/local ]; then
cath <<EOF

Standalone release has been installed into /usr/local/bin/coder
cath <<EOF
Standalone release has been installed into $STANDALONE_INSTALL_PREFIX/bin/$STANDALONE_BINARY_NAME

EOF
else
cath <<EOF
Standalone release has been installed into $STANDALONE_INSTALL_PREFIX/bin/coder

if [ "$STANDALONE_INSTALL_PREFIX" != /usr/local ]; then
cath <<EOF
Extend your path to use Coder:
PATH="$STANDALONE_INSTALL_PREFIX/bin:\$PATH"

EOF
fi
cath <<EOF
Run Coder (temporary):
coder server --dev
$STANDALONE_BINARY_NAME server --dev

Or run a production deployment with PostgreSQL:
CODER_PG_CONNECTION_URL="postgres://<username>@<host>/<database>?password=<password>" \\
coder server
$STANDALONE_BINARY_NAME server

EOF
}
Expand Down Expand Up @@ -165,6 +167,13 @@ main() {
--prefix=*)
STANDALONE_INSTALL_PREFIX="$(parse_arg "$@")"
;;
--binary-name)
STANDALONE_BINARY_NAME="$(parse_arg "$@")"
shift
;;
--binary-name=*)
STANDALONE_BINARY_NAME="$(parse_arg "$@")"
;;
--version)
VERSION="$(parse_arg "$@")"
shift
Expand Down Expand Up @@ -225,6 +234,7 @@ main() {
# releases in order to download and unpack the right release.
CACHE_DIR=$(echo_cache_dir)
STANDALONE_INSTALL_PREFIX=${STANDALONE_INSTALL_PREFIX:-/usr/local}
STANDALONE_BINARY_NAME=${STANDALONE_BINARY_NAME:-coder}
VERSION=${VERSION:-$(echo_latest_version)}
# These can be overridden for testing but shouldn't normally be used as it can
# result in a broken coder.
Expand Down Expand Up @@ -381,7 +391,7 @@ install_standalone() {
"$sh_c" unzip -d "$CACHE_DIR" -o "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.zip"
fi

"$sh_c" cp "$CACHE_DIR/coder" "$STANDALONE_INSTALL_PREFIX/bin/coder"
"$sh_c" cp "$CACHE_DIR/coder" "$STANDALONE_INSTALL_PREFIX/bin/$STANDALONE_BINARY_NAME"

echo_standalone_postinstall
}
Expand Down