1
1
#! /bin/sh
2
2
set -eu
3
3
4
+ MINIMUM_LIBC=2.17
5
+
4
6
usage () {
5
- cat << EOF
6
- $0 [--dry-run] [--version X.X.X] [--static <install-prefix>=~/.local]
7
+ cli=" $0 "
8
+ if [ " $0 " = sh ]; then
9
+ cli=" curl -fsSL https://code-server.dev/install.sh | sh -s --"
10
+ else
11
+ curl_usage=" $( cat << EOF
12
+
13
+ To use latest:
7
14
8
- Installs latest code-server on any macOS or Linux system preferring to use the OS package manager.
15
+ curl -fsSL https://code-server.dev/install.sh | sh -s -- <args>
16
+ EOF)""
17
+ "
18
+ fi
19
+ cat <<EOF
20
+ Installs latest code-server on Linux or macOS preferring to use the system package manager.
21
+
22
+ Lives at https://code-server.dev/install.sh
9
23
10
- curl -fsSL https://code-server.dev/install.sh | sh -s --
24
+ Usage:
11
25
26
+ $cli [--dry-run] [--version X.X.X] [--static <install-prefix>=~/.local]
27
+ ${curl_usage-}
12
28
- For Debian, Ubuntu, Raspbian it will install the latest deb package.
13
29
- For Fedora, CentOS, RHEL, openSUSE it will install the latest rpm package.
14
30
- For Arch Linux it will install the AUR package.
@@ -19,7 +35,7 @@ Installs latest code-server on any macOS or Linux system preferring to use the O
19
35
- If Homebrew is not installed it will install the latest static release into ~/.local
20
36
- Add ~/.local/bin to your \$ PATH to run code-server.
21
37
22
- - If ran on an architecture with no binary releases or outdated libc/libcxx , it will install the
38
+ - If ran on an architecture with no binary releases or glibc < v $MINIMUM_LIBC , it will install the
23
39
npm package with yarn or npm.
24
40
- We only have binary releases for amd64 and arm64 presently.
25
41
40
56
}
41
57
42
58
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 } "
59
+ # https://gist .github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-2758860
60
+ version= " $( curl -fsSLI -o /dev/null -w %{url_effective} -o /dev/null -w %{url_effective} https://github.com/cdr/code-server/releases/latest ) "
61
+ version=" ${version# https :// github.com / cdr / code-server / releases / tag / v } "
46
62
echo " $version "
47
63
}
48
64
49
65
echo_static_postinstall () {
50
66
echo
51
- cat << EOF
67
+ cat << EOF
52
68
Static release has been installed into $STATIC_INSTALL_PREFIX /lib/code-server-$VERSION
53
69
Please extend your path to use code-server:
54
70
PATH="$STATIC_INSTALL_PREFIX /bin:\$ PATH"
59
75
60
76
echo_systemd_postinstall () {
61
77
echo
62
- cat << EOF
78
+ cat << EOF
63
79
To have systemd start code-server now and restart on boot:
64
80
systemctl --user enable --now code-server
65
81
Or, if you don't want/need a background service you can run:
@@ -147,6 +163,11 @@ main() {
147
163
return
148
164
fi
149
165
166
+ if [ " $OS " = " linux" ] && outdated_glibc; then
167
+ install_static
168
+ return
169
+ fi
170
+
150
171
case " $( distro) " in
151
172
macos)
152
173
install_macos
@@ -386,7 +407,7 @@ arch() {
386
407
}
387
408
388
409
command_exists () {
389
- command -v " $@ " > /dev/null 2>&1
410
+ command -v " $@ " > /dev/null 2>&1
390
411
}
391
412
392
413
sh_c () {
@@ -429,4 +450,9 @@ echoerr() {
429
450
echo " $@ " >&2
430
451
}
431
452
453
+ outdated_glibc () {
454
+ glibc_version=" $( ldd --version | grep -m 1 -o ' [0-9.]\+$' ) "
455
+ echo " $glibc_version "
456
+ }
457
+
432
458
main " $@ "
0 commit comments