forked from jenkinsci/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-node-env.sh
More file actions
executable file
·39 lines (33 loc) · 995 Bytes
/
install-node-env.sh
File metadata and controls
executable file
·39 lines (33 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash -eu
install() {
local nodeVersion nodePkgName nodeInstallPath
if [[ $# -eq 1 ]] && [[ -n $1 ]]; then
nodeVersion="$1"
else
nodeVersion="v6.11.1";
fi
nodeInstallPath="/usr/lib/"
nodePkgName="node-$nodeVersion-linux-x64"
doDownload "$nodeVersion $nodePkgName"
tar -xvf "/tmp/$nodePkgName.tar.xz" -C "$nodeInstallPath"
ln -s "$nodeInstallPath/$nodePkgName/bin/node" "/usr/local/bin/node"
ln -s "$nodeInstallPath/$nodePkgName/bin/npm" "/usr/local/bin/npm"
}
doDownload() {
local url nodeVersion nodePkgName pkgPath
nodeVersion="$1"
nodePkgName="$2"
url="https://nodejs.org/dist/$nodeVersion/$nodePkgName.tar.xz"
pkgPath="/tmp"
cd "$pkgPath"
echo "Downloading Node.js $nodeVersion from $url"
curl --retry "3" --retry-delay "0" --retry-max-time "5" -# -O "$url"
}
main() {
local nodeVersion
if [[ $# -eq 1 ]]; then
nodeVersion="$1";
fi
install "$nodeVersion"
}
main "$@"