11#! /bin/sh
22set -eu
33
4+ MINIMUM_LIBC=2.17
5+
46usage () {
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:
714
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
923
10- curl -fsSL https://code-server.dev/install.sh | sh -s --
24+ Usage:
1125
26+ $cli [--dry-run] [--version X.X.X] [--static <install-prefix>=~/.local]
27+ ${curl_usage-}
1228- For Debian, Ubuntu, Raspbian it will install the latest deb package.
1329- For Fedora, CentOS, RHEL, openSUSE it will install the latest rpm package.
1430- 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
1935 - If Homebrew is not installed it will install the latest static release into ~/.local
2036 - Add ~/.local/bin to your \$ PATH to run code-server.
2137
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
2339 npm package with yarn or npm.
2440 - We only have binary releases for amd64 and arm64 presently.
2541
4056}
4157
4258echo_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 } "
4662 echo " $version "
4763}
4864
4965echo_static_postinstall () {
5066 echo
51- cat << EOF
67+ cat << EOF
5268Static release has been installed into $STATIC_INSTALL_PREFIX /lib/code-server-$VERSION
5369Please extend your path to use code-server:
5470 PATH="$STATIC_INSTALL_PREFIX /bin:\$ PATH"
5975
6076echo_systemd_postinstall () {
6177 echo
62- cat << EOF
78+ cat << EOF
6379To have systemd start code-server now and restart on boot:
6480 systemctl --user enable --now code-server
6581Or, if you don't want/need a background service you can run:
@@ -147,6 +163,11 @@ main() {
147163 return
148164 fi
149165
166+ if [ " $OS " = " linux" ] && outdated_glibc; then
167+ install_static
168+ return
169+ fi
170+
150171 case " $( distro) " in
151172 macos)
152173 install_macos
@@ -386,7 +407,7 @@ arch() {
386407}
387408
388409command_exists () {
389- command -v " $@ " > /dev/null 2>&1
410+ command -v " $@ " > /dev/null 2>&1
390411}
391412
392413sh_c () {
@@ -429,4 +450,9 @@ echoerr() {
429450 echo " $@ " >&2
430451}
431452
453+ outdated_glibc () {
454+ glibc_version=" $( ldd --version | grep -m 1 -o ' [0-9.]\+$' ) "
455+ echo " $glibc_version "
456+ }
457+
432458main " $@ "
0 commit comments