-
Notifications
You must be signed in to change notification settings - Fork 5.9k
install.sh: Allow installing directly onto a remote host #2183
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,21 +17,28 @@ usage() { | |
Installs code-server for Linux, macOS and FreeBSD. | ||
It tries to use the system package manager if possible. | ||
After successful installation it explains how to start using code-server. | ||
|
||
Pass in user@host to install code-server on user@host over ssh. | ||
The remote host must have internet access. | ||
${not_curl_usage-} | ||
Usage: | ||
|
||
$arg0 [--dry-run] [--version X.X.X] [--method detect] [--prefix ~/.local] | ||
$arg0 [--dry-run] [--version X.X.X] [--method detect] \ | ||
[--prefix ~/.local] [user@host] | ||
|
||
--dry-run | ||
Echo the commands for the install process without running them. | ||
|
||
--version X.X.X | ||
Install a specific version instead of the latest. | ||
|
||
--method [detect | standalone] | ||
Choose the installation method. Defaults to detect. | ||
- detect detects the system package manager and tries to use it. | ||
Full reference on the process is further below. | ||
- standalone installs a standalone release archive into ~/.local | ||
Add ~/.local/bin to your \$PATH to use it. | ||
|
||
--prefix <dir> | ||
Sets the prefix used by standalone release archives. Defaults to ~/.local | ||
The release is unarchived into ~/.local/lib/code-server-X.X.X | ||
|
@@ -100,9 +107,18 @@ main() { | |
METHOD \ | ||
STANDALONE_INSTALL_PREFIX \ | ||
VERSION \ | ||
OPTIONAL | ||
OPTIONAL \ | ||
ALL_FLAGS \ | ||
SSH_ARGS | ||
|
||
ALL_FLAGS="" | ||
while [ "$#" -gt 0 ]; do | ||
case "$1" in | ||
-*) | ||
ALL_FLAGS="${ALL_FLAGS} $1" | ||
;; | ||
esac | ||
|
||
case "$1" in | ||
--dry-run) | ||
DRY_RUN=1 | ||
|
@@ -132,16 +148,33 @@ main() { | |
usage | ||
exit 0 | ||
;; | ||
*) | ||
--) | ||
shift | ||
# We remove the -- added above. | ||
ALL_FLAGS="${ALL_FLAGS% --}" | ||
SSH_ARGS="$*" | ||
break | ||
;; | ||
-*) | ||
echoerr "Unknown flag $1" | ||
echoerr "Run with --help to see usage." | ||
exit 1 | ||
;; | ||
*) | ||
SSH_ARGS="$*" | ||
break | ||
;; | ||
esac | ||
|
||
shift | ||
done | ||
|
||
if [ "${SSH_ARGS-}" ]; then | ||
echoh "Installing remotely with ssh $SSH_ARGS" | ||
curl -fsSL https://code-server.dev/install.sh | prefix "$SSH_ARGS" ssh "$SSH_ARGS" sh -s -- "$ALL_FLAGS" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh no need to mess with |
||
return | ||
fi | ||
|
||
VERSION="${VERSION-$(echo_latest_version)}" | ||
METHOD="${METHOD-detect}" | ||
if [ "$METHOD" != detect ] && [ "$METHOD" != standalone ]; then | ||
|
@@ -446,7 +479,7 @@ arch() { | |
} | ||
|
||
command_exists() { | ||
command -v "$@" > /dev/null 2>&1 | ||
command -v "$@" > /dev/null | ||
} | ||
|
||
sh_c() { | ||
|
@@ -500,4 +533,15 @@ humanpath() { | |
sed "s# $HOME# ~#g; s#\"$HOME#\"\$HOME#g" | ||
} | ||
|
||
# We need to make sure we exit with a non zero exit if the command fails. | ||
# /bin/sh does not support -o pipefail unfortunately. | ||
prefix() { | ||
PREFIX="$1" | ||
shift | ||
fifo="$(mktemp -d)/fifo" | ||
mkfifo "$fifo" | ||
sed -e "s#^#$PREFIX: #" "$fifo" & | ||
"$@" > "$fifo" 2>&1 | ||
} | ||
|
||
main "$@" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to set
SSH_ARGS
as well I think to avoid unbound errors.