2016-09-21 08:44:01 +02:00
|
|
|
#!/usr/bin/env bash
|
2021-09-23 02:49:03 +02:00
|
|
|
set -euo pipefail
|
|
|
|
|
2022-09-03 02:55:17 +02:00
|
|
|
version=16.17.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"
|
2022-09-03 02:55:17 +02:00
|
|
|
sha256=f0867d7a17a4d0df7dbb7df9ac3f9126c2b58f75450647146749ef296b31b49b
|
2021-09-23 02:49:03 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
aarch64)
|
|
|
|
tarball="node-v$version-linux-arm64.tar.xz"
|
2022-09-03 02:55:17 +02:00
|
|
|
sha256=a43100595e7960b9e8364bff5641e0956a9929feee2759e70cbb396a1d827b7c
|
2021-09-23 02:49:03 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
check_version() {
|
|
|
|
out="$(node --version)" && [ "$out" = "v$version" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
if ! check_version; then
|
|
|
|
tmpdir="$(mktemp -d)"
|
|
|
|
trap 'rm -r "$tmpdir"' EXIT
|
|
|
|
cd "$tmpdir"
|
|
|
|
curl_opts=(-fLO)
|
|
|
|
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
|
|
|
|
ln -sf /srv/zulip-node/bin/{node,npm,npx} /usr/local/bin
|
|
|
|
rm -rf /usr/local/nvm
|
|
|
|
check_version
|
2017-07-27 23:17:52 +02:00
|
|
|
fi
|