-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path020-node
executable file
·95 lines (79 loc) · 2.43 KB
/
020-node
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# Install Node + common NPM packages
source common
# Node version to install, ideally a EVEN (LTS) numbered, tested, stable version
NODE_VERSION=20
if [ `which 'node' >/dev/null; echo "$?"` == 0 ]; then
INIT status "Remove existing Node installs"
sudo apt purge nodejs
if [ `which node >/dev/null; echo "$?"` == 0 ]; then
sudo rm `which node`
fi
fi
if [ -e "/etc/apt/keyrings/nodesource.gpg" ]; then
INIT skip "Install Nodesource GPG keys"
else
INIT status "Install Nodesource GPG keys"
INIT apt-install --lazy ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings 2>/dev/null
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
fi
if [ -e "/etc/apt/sources.list.d/nodesource_${NODE_VERSION}.list" ]; then
INIT skip "Install Apt reference for Node ${NODE_VERSION}"
else
INIT status "Install Apt reference for Node ${NODE_VERSION}"
INIT file-set "/etc/apt/sources.list.d/nodesource_${NODE_VERSION}.list" <<EOF
deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x nodistro main
EOF
fi
INIT status "Install Node from Apt"
INIT apt-update
INIT apt-install nodejs
if [ -e "$HOME/.npmrc" ]; then
INIT skip "NPM config already exists"
else
INIT status "Install NPM config"
echo 'email=m@ttcarter.com' >~/.npmrc
echo 'bin-links=true' >>~/.npmrc
echo 'save=true' >>~/.npmrc
echo 'spin=false' >>~/.npmrc
echo 'loglevel=http' >>~/.npmrc
echo 'registry=https://registry.npmjs.org' >>~/.npmrc
fi
INIT status "Upgrade NPM to latest"
INIT npm-install -g npm@latest
INIT status "Install common global NPMs"
INIT npm-install \
@hash-bang/pss \
@momsfriendlydevco/cli-snip \
@momsfriendlydevco/extract \
@momsfriendlydevco/o \
@momsfriendlydevco/repl \
depcheck \
fkill-cli \
fx \
gronk \
gulp \
hanson \
jay-repl \
jaywalker \
jshint \
json-prettify \
mongoosh \
mocha \
npm-check-updates \
INIT status "Permit Node to have port 80 access"
INIT apt-install --lazy libcap2-bin
sudo setcap cap_net_bind_service=+ep /usr/bin/node
INIT status "Setup NODE_ENV"
if [ `INIT file-grep-matches "$HOME/.bashrc" "NODE_ENV"` == 1 ]; then
INIT skip "NODE_ENV already setup"
else
echo "Installing NODE_ENV into ~/.bashrc, assuming 'production'"
echo "export NODE_ENV=production" >>~/.bashrc
export NODE_ENV=production
fi
if [ -d "/tmp/npm" ]; then
INIT status "Reset permissions on /tmp/npm"
sudo chmod 0777 -R /tmp/npm
fi