2
2
set -eu
3
3
4
4
usage () {
5
+ cli=" $0 "
6
+ if [ " $0 " = sh ]; then
7
+ cli=" curl -fsSL https://code-server.dev/install.sh | sh -s --"
8
+ else
9
+ curl_usage=" $(
10
+ cat << EOF
11
+
12
+ To use latest:
13
+
14
+ curl -fsSL https://code-server.dev/install.sh | sh -s -- <args>
15
+ EOF
16
+ ) " $" \n"
17
+ fi
5
18
cat << EOF
6
- $0 [--dry-run] [--version X.X.X] [--static <install-prefix>=~/.local]
19
+ Installs latest code-server on Linux or macOS preferring to use the system package manager.
7
20
8
- Installs latest code-server on any macOS or Linux system preferring to use the OS package manager.
21
+ Lives at https:// code-server.dev/install.sh
9
22
10
- curl -fsSL https://code-server.dev/install.sh | sh -s --
23
+ Usage:
11
24
25
+ $cli [--dry-run] [--version X.X.X] [--static <install-prefix>=~/.local]
26
+ ${curl_usage-}
12
27
- For Debian, Ubuntu, Raspbian it will install the latest deb package.
13
28
- For Fedora, CentOS, RHEL, openSUSE it will install the latest rpm package.
14
29
- For Arch Linux it will install the AUR package.
@@ -19,8 +34,7 @@ Installs latest code-server on any macOS or Linux system preferring to use the O
19
34
- If Homebrew is not installed it will install the latest static release into ~/.local
20
35
- Add ~/.local/bin to your \$ PATH to run code-server.
21
36
22
- - If ran on an architecture with no binary releases or outdated libc/libcxx, it will install the
23
- npm package with yarn or npm.
37
+ - If ran on an architecture with no binary releases, it will install the npm package with yarn or npm.
24
38
- We only have binary releases for amd64 and arm64 presently.
25
39
26
40
--dry-run Enables a dry run where where the steps that would have taken place
40
54
}
41
55
42
56
echo_latest_version () {
43
- version= " $( curl -fsSL https://api .github.com/repos/cdr/code-server/releases/latest | jq -r .tag_name ) "
44
- # Strip leading v.
45
- version=" ${version: 1 } "
57
+ # https://gist .github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-2758860
58
+ version= " $( curl -fsSLI -o /dev/null -w " %{url_effective} " https://github.com/cdr/code-server/releases/latest ) "
59
+ version=" ${version# https :// github.com / cdr / code-server / releases / tag / v } "
46
60
echo " $version "
47
61
}
48
62
@@ -172,7 +186,7 @@ parse_arg() {
172
186
* =* )
173
187
opt=" ${1# =* } "
174
188
optarg=" ${1#* =} "
175
- if [ ! " $optarg " -a ! " ${OPTIONAL-} " ]; then
189
+ if [ ! " $optarg " ] && [ ! " ${OPTIONAL-} " ]; then
176
190
echoerr " $opt requires an argument"
177
191
echoerr " Run with --help to see usage."
178
192
exit 1
@@ -183,7 +197,7 @@ parse_arg() {
183
197
esac
184
198
185
199
case " ${2-} " in
186
- " " | -* | -- * )
200
+ " " | -* )
187
201
if [ ! " ${OPTIONAL-} " ]; then
188
202
echoerr " $1 requires an argument"
189
203
echoerr " Run with --help to see usage."
@@ -282,7 +296,7 @@ install_static() {
282
296
fi
283
297
SKIP_ECHO=1 sh_c mkdir -p " $STATIC_INSTALL_PREFIX /lib" " $STATIC_INSTALL_PREFIX /bin"
284
298
285
- if [[ -e " $STATIC_INSTALL_PREFIX /lib/code-server-$VERSION " ] ]; then
299
+ if [ -e " $STATIC_INSTALL_PREFIX /lib/code-server-$VERSION " ]; then
286
300
echo
287
301
echoerr " code-server-$VERSION is already installed at $STATIC_INSTALL_PREFIX /lib/code-server-$VERSION "
288
302
echoerr " Please remove it to reinstall."
@@ -339,21 +353,20 @@ distro() {
339
353
return
340
354
fi
341
355
342
- if [ ! -f /etc/os-release ]; then
356
+ if [ -f /etc/os-release ]; then
357
+ (
358
+ . /etc/os-release
359
+ case " $ID " in opensuse-* )
360
+ # opensuse's ID's look like opensuse-leap and opensuse-tumbleweed.
361
+ echo " opensuse"
362
+ return
363
+ ;;
364
+ esac
365
+
366
+ echo " $ID "
367
+ )
343
368
return
344
369
fi
345
-
346
- (
347
- . /etc/os-release
348
- case " $ID " in opensuse-* )
349
- # opensuse's ID's look like opensuse-leap and opensuse-tumbleweed.
350
- echo " opensuse"
351
- return
352
- ;;
353
- esac
354
-
355
- echo " $ID "
356
- )
357
370
}
358
371
359
372
# os_name prints a pretty human readable name for the OS/Distro.
@@ -363,11 +376,12 @@ distro_name() {
363
376
return
364
377
fi
365
378
366
- if [ ! -f /etc/os-release ]; then
379
+ if [ -f /etc/os-release ]; then
367
380
(
368
381
. /etc/os-release
369
382
echo " $PRETTY_NAME "
370
383
)
384
+ return
371
385
fi
372
386
373
387
# Prints something like: Linux 4.19.0-9-amd64
0 commit comments