@@ -17,21 +17,28 @@ usage() {
17
17
Installs code-server for Linux, macOS and FreeBSD.
18
18
It tries to use the system package manager if possible.
19
19
After successful installation it explains how to start using code-server.
20
+
21
+ Pass in user@host to install code-server on user@host over ssh.
22
+ The remote host must have internet access.
20
23
${not_curl_usage-}
21
24
Usage:
22
25
23
- $arg0 [--dry-run] [--version X.X.X] [--method detect] [--prefix ~/.local]
26
+ $arg0 [--dry-run] [--version X.X.X] [--method detect] \
27
+ [--prefix ~/.local] [user@host]
24
28
25
29
--dry-run
26
30
Echo the commands for the install process without running them.
31
+
27
32
--version X.X.X
28
33
Install a specific version instead of the latest.
34
+
29
35
--method [detect | standalone]
30
36
Choose the installation method. Defaults to detect.
31
37
- detect detects the system package manager and tries to use it.
32
38
Full reference on the process is further below.
33
39
- standalone installs a standalone release archive into ~/.local
34
40
Add ~/.local/bin to your \$ PATH to use it.
41
+
35
42
--prefix <dir>
36
43
Sets the prefix used by standalone release archives. Defaults to ~/.local
37
44
The release is unarchived into ~/.local/lib/code-server-X.X.X
@@ -100,9 +107,18 @@ main() {
100
107
METHOD \
101
108
STANDALONE_INSTALL_PREFIX \
102
109
VERSION \
103
- OPTIONAL
110
+ OPTIONAL \
111
+ ALL_FLAGS \
112
+ SSH_ARGS
104
113
114
+ ALL_FLAGS=" "
105
115
while [ " $# " -gt 0 ]; do
116
+ case " $1 " in
117
+ -* )
118
+ ALL_FLAGS=" ${ALL_FLAGS} $1 "
119
+ ;;
120
+ esac
121
+
106
122
case " $1 " in
107
123
--dry-run)
108
124
DRY_RUN=1
@@ -132,16 +148,33 @@ main() {
132
148
usage
133
149
exit 0
134
150
;;
135
- * )
151
+ --)
152
+ shift
153
+ # We remove the -- added above.
154
+ ALL_FLAGS=" ${ALL_FLAGS% --} "
155
+ SSH_ARGS=" $* "
156
+ break
157
+ ;;
158
+ -* )
136
159
echoerr " Unknown flag $1 "
137
160
echoerr " Run with --help to see usage."
138
161
exit 1
139
162
;;
163
+ * )
164
+ SSH_ARGS=" $* "
165
+ break
166
+ ;;
140
167
esac
141
168
142
169
shift
143
170
done
144
171
172
+ if [ " ${SSH_ARGS-} " ]; then
173
+ echoh " Installing remotely with ssh $SSH_ARGS "
174
+ curl -fsSL https://code-server.dev/install.sh | prefix " $SSH_ARGS " ssh " $SSH_ARGS " sh -s -- " $ALL_FLAGS "
175
+ return
176
+ fi
177
+
145
178
VERSION=" ${VERSION-$(echo_latest_version)} "
146
179
METHOD=" ${METHOD-detect} "
147
180
if [ " $METHOD " != detect ] && [ " $METHOD " != standalone ]; then
@@ -446,7 +479,7 @@ arch() {
446
479
}
447
480
448
481
command_exists () {
449
- command -v " $@ " > /dev/null 2>&1
482
+ command -v " $@ " > /dev/null
450
483
}
451
484
452
485
sh_c () {
@@ -500,4 +533,15 @@ humanpath() {
500
533
sed " s# $HOME # ~#g; s#\" $HOME #\"\$ HOME#g"
501
534
}
502
535
536
+ # We need to make sure we exit with a non zero exit if the command fails.
537
+ # /bin/sh does not support -o pipefail unfortunately.
538
+ prefix () {
539
+ PREFIX=" $1 "
540
+ shift
541
+ fifo=" $( mktemp -d) /fifo"
542
+ mkfifo " $fifo "
543
+ sed -e " s#^#$PREFIX : #" " $fifo " &
544
+ " $@ " > " $fifo " 2>&1
545
+ }
546
+
503
547
main " $@ "
0 commit comments