2016-09-21 08:44:01 +02:00
|
|
|
#!/usr/bin/env bash
|
2021-09-23 02:49:03 +02:00
|
|
|
set -euo pipefail
|
|
|
|
|
2023-11-09 00:24:24 +01:00
|
|
|
version=20.9.0
|
2021-09-23 02:49:03 +02:00
|
|
|
arch="$(uname -m)"
|
|
|
|
|
|
|
|
case $arch in
|
|
|
|
x86_64)
|
|
|
|
tarball="node-v$version-linux-x64.tar.xz"
|
2023-11-09 00:24:24 +01:00
|
|
|
sha256=9033989810bf86220ae46b1381bdcdc6c83a0294869ba2ad39e1061f1e69217a
|
2021-09-23 02:49:03 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
aarch64)
|
|
|
|
tarball="node-v$version-linux-arm64.tar.xz"
|
2023-11-09 00:24:24 +01:00
|
|
|
sha256=ced3ecece4b7c3a664bca3d9e34a0e3b9a31078525283a6fdb7ea2de8ca5683b
|
2021-09-23 02:49:03 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
check_version() {
|
2023-02-09 01:13:42 +01:00
|
|
|
out="$(node --version)" && [ "$out" = "v$version" ] \
|
2023-03-20 19:52:59 +01:00
|
|
|
&& [ /usr/local/bin/pnpm -ef /srv/zulip-node/lib/node_modules/corepack/dist/pnpm.js ]
|
2021-09-23 02:49:03 +02:00
|
|
|
}
|
|
|
|
|
2022-11-03 18:15:10 +01:00
|
|
|
if ! check_version 2>/dev/null; then
|
2023-05-10 20:32:00 +02:00
|
|
|
set -x
|
2021-09-23 02:49:03 +02:00
|
|
|
tmpdir="$(mktemp -d)"
|
|
|
|
trap 'rm -r "$tmpdir"' EXIT
|
|
|
|
cd "$tmpdir"
|
2022-11-07 22:50:24 +01:00
|
|
|
curl_opts=(-fLO --retry 3)
|
2021-09-23 02:49:03 +02:00
|
|
|
if [ -n "${CUSTOM_CA_CERTIFICATES:-}" ]; then
|
|
|
|
curl_opts+=(--cacert "${CUSTOM_CA_CERTIFICATES}")
|
2017-07-27 23:17:52 +02:00
|
|
|
fi
|
2021-09-23 02:49:03 +02:00
|
|
|
curl "${curl_opts[@]}" "https://nodejs.org/dist/v$version/$tarball"
|
|
|
|
sha256sum -c <<<"$sha256 $tarball"
|
|
|
|
rm -rf /srv/zulip-node
|
|
|
|
mkdir -p /srv/zulip-node
|
|
|
|
tar -xJf "$tarball" --no-same-owner --strip-components=1 -C /srv/zulip-node
|
2023-02-09 01:13:42 +01:00
|
|
|
ln -sf /srv/zulip-node/bin/{corepack,node,npm,npx} /usr/local/bin
|
|
|
|
COREPACK_DEFAULT_TO_LATEST=0 /usr/local/bin/corepack enable
|
|
|
|
|
|
|
|
# Clean up after previous versions of this script
|
|
|
|
rm -rf /srv/zulip-yarn /usr/bin/yarn /usr/local/nvm
|
|
|
|
|
2021-09-23 02:49:03 +02:00
|
|
|
check_version
|
2017-07-27 23:17:52 +02:00
|
|
|
fi
|