2
2
set -eu
3
3
4
4
usage () {
5
- cat << EOF
5
+ cat << EOF
6
6
$0 [--dry-run] [--version X.X.X] [--static <install-prefix>=~/.local]
7
7
8
8
Installs latest code-server on any macOS or Linux system preferring to use the OS package manager.
@@ -48,18 +48,18 @@ echo_latest_version() {
48
48
49
49
echo_static_postinstall () {
50
50
echo
51
- cat << EOF
52
- Static release has been installed into $STATIC_INSTALL_PREFIX /code-server-$VERSION
51
+ cat << EOF
52
+ Static release has been installed into $STATIC_INSTALL_PREFIX /lib/ code-server-$VERSION
53
53
Please extend your path to use code-server:
54
- PATH="$STATIC_INSTALL_PREFIX /code-server- $VERSION / bin:\$ PATH"
54
+ PATH="$STATIC_INSTALL_PREFIX /bin:\$ PATH"
55
55
Then you can run:
56
56
code-server
57
57
EOF
58
58
}
59
59
60
60
echo_systemd_postinstall () {
61
61
echo
62
- cat << EOF
62
+ cat << EOF
63
63
To have systemd start code-server now and restart on boot:
64
64
systemctl --user enable --now code-server
65
65
Or, if you don't want/need a background service you can run:
@@ -76,7 +76,7 @@ main() {
76
76
DRY_RUN \
77
77
STATIC \
78
78
STATIC_INSTALL_PREFIX \
79
- SKIP_LOG \
79
+ SKIP_ECHO \
80
80
VERSION \
81
81
OPTIONAL
82
82
@@ -118,12 +118,7 @@ main() {
118
118
done
119
119
120
120
VERSION=" ${VERSION-$(echo_latest_version)} "
121
- STATIC_INSTALL_PREFIX=" ${STATIC_INSATLL_PREFIX-$HOME / .local} "
122
-
123
- echo " ${DRY_RUN-} "
124
- echo " ${STATIC_INSTALL_PREFIX-} "
125
- echo " ${VERSION-} "
126
- exit 1
121
+ STATIC_INSTALL_PREFIX=" ${STATIC_INSTALL_PREFIX-$HOME / .local} "
127
122
128
123
OS=" $( os) "
129
124
if [ ! " $OS " ]; then
@@ -144,7 +139,7 @@ main() {
144
139
exit 0
145
140
fi
146
141
147
- CACHE_DIR=" $( cache_dir ) "
142
+ CACHE_DIR=" $( echo_cache_dir ) "
148
143
mkdir -p " $CACHE_DIR "
149
144
150
145
if [ " ${STATIC-} " ]; then
@@ -217,7 +212,7 @@ fetch() {
217
212
-Ro " $FILE .incomplete" \
218
213
-C - \
219
214
" $URL "
220
- mv " $FILE .incomplete" " $FILE "
215
+ SKIP_ECHO=1 sh_c mv " $FILE .incomplete" " $FILE "
221
216
}
222
217
223
218
install_macos () {
@@ -260,7 +255,7 @@ install_aur() {
260
255
tmp_dir=" $( mktemp -d) "
261
256
(
262
257
cd " $tmp_dir "
263
- tar -xzf " $CACHE_DIR /code-server-aur.tar.gz" --strip-components 1
258
+ SKIP_ECHO=1 sh_c tar -xzf " $CACHE_DIR /code-server-aur.tar.gz" --strip-components 1
264
259
sh_c makepkg -si
265
260
)
266
261
rm -Rf " $tmp_dir "
@@ -285,11 +280,16 @@ install_static() {
285
280
if [ ! -w " $STATIC_INSTALL_PREFIX " ]; then
286
281
sh_c=" sudo_sh_c"
287
282
fi
283
+ SKIP_ECHO=1 sh_c mkdir -p " $STATIC_INSTALL_PREFIX /lib" " $STATIC_INSTALL_PREFIX /bin"
288
284
289
- " $sh_c " tar -C " $STATIC_INSTALL_PREFIX " -xzf " $CACHE_DIR /code-server-$VERSION -$OS -$ARCH .tar.gz"
290
- # In case previously installed.
291
- SKIP_LOG=1 " $sh_c " rm -Rf " $STATIC_INSTALL_PREFIX /code-server-$VERSION "
292
- " $sh_c " mv -f " $STATIC_INSTALL_PREFIX /code-server-$VERSION -$OS -$ARCH " " $STATIC_INSTALL_PREFIX /code-server-$VERSION "
285
+ if [[ -e " $STATIC_INSTALL_PREFIX /lib/code-server-$VERSION " ]]; then
286
+ echo
287
+ echoerr " code-server-$VERSION is already installed at $STATIC_INSTALL_PREFIX /lib/code-server-$VERSION "
288
+ echoerr " Please remove it to reinstall."
289
+ exit 1
290
+ fi
291
+ " $sh_c " tar -C " $STATIC_INSTALL_PREFIX /lib" -xzf " $CACHE_DIR /code-server-$VERSION -$OS -$ARCH .tar.gz"
292
+ " $sh_c " mv -f " $STATIC_INSTALL_PREFIX /lib/code-server-$VERSION -$OS -$ARCH " " $STATIC_INSTALL_PREFIX /lib/code-server-$VERSION "
293
293
294
294
echo_static_postinstall
295
295
}
@@ -386,11 +386,11 @@ arch() {
386
386
}
387
387
388
388
command_exists () {
389
- command -v " $@ " > /dev/null 2>&1
389
+ command -v " $@ " > /dev/null 2>&1
390
390
}
391
391
392
392
sh_c () {
393
- if [ ! " ${SKIP_LOG -} " ]; then
393
+ if [ ! " ${SKIP_ECHO -} " ]; then
394
394
echo
395
395
echo " + $* "
396
396
fi
0 commit comments