-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodejs.bits
More file actions
45 lines (35 loc) · 864 Bytes
/
nodejs.bits
File metadata and controls
45 lines (35 loc) · 864 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
40
41
42
43
44
45
#!/bin/bash
#-----------
# VARIABLES
#-----------
NODE_VERSION=${NODE_VERSION-11.9.0}
#-----------
# HELPERS
#-----------
set_env()
{
KEY=$1
VAL=$2
echo "export $KEY=$VAL" >> $HOME/.bash_aliases
}
#-----------
# INSTALLER
#-----------
if [[ "$NODE_VERSION" == "latest" ]]; then
(mkdir -p /opt/node/latest && \
cd /opt/node/latest && \
apt-get update && \
apt-get install -y g++ make && \
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 && \
./configure && \
make && \
make install)
else
(mkdir -p /opt/node && \
cd /opt/node && \
wget https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz && \
tar zxf node-v$NODE_VERSION-linux-x64.tar.gz)
set_env PATH "/opt/node/node-v$NODE_VERSION-linux-x64/bin:\$PATH"
source $HOME/.bash_aliases
fi
touch /opt/nodejs.bits