-
Notifications
You must be signed in to change notification settings - Fork 2
/
install
executable file
·73 lines (57 loc) · 2.02 KB
/
install
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
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
if [[ -d "/opt/nvm" && -f "/usr/local/hestia/data/templates/web/nginx/NodeApp.stpl" ]]
then
echo "NodeApp appears to already be installed"
exit
fi
############################################
# Install NVM, NodeJS, PM2, and grunt
############################################
# NVM and prerequisites
apt-get install -y curl gnupg2
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.bashrc
# Install node version manager, globally
mv ~/.nvm /opt/nvm
chmod -R 755 /opt/nvm
export NVM_DIR="/opt/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export PATH="/opt/nvm:$PATH"
# Initial install of NodeJS (version 20 is an LTS version)
nvm install v20
npm install -g npm@latest
# Install last three NodeJS LTS versions
nvm install v16
nvm install v18
nvm alias default v20
# Install grunt, pm2 globally for all versions
nvm use v16
npm install -g grunt-cli
npm install -g pm2
nvm use v18
npm install -g grunt-cli
npm install -g pm2
nvm use v20
npm install -g grunt-cli
npm install -g pm2
############################################
# Install templates
############################################
rsync -r ./nginx/ /usr/local/hestia/data/templates/web/nginx/
############################################
# Update global bash.bashrc
############################################
if ! grep -Fxq "# begin hcpp-nodeapp" "/etc/bash.bashrc";then
cat <<EOT >> /etc/bash.bashrc
# begin hcpp-nodeapp
export NVM_DIR="/opt/nvm"
[ -s "\$NVM_DIR/nvm.sh" ] && \. "\$NVM_DIR/nvm.sh" # This loads nvm
[ -s "\$NVM_DIR/bash_completion" ] && \. "\$NVM_DIR/bash_completion" # This loads nvm bash_completion
export PATH="/opt/nvm:\$PATH"
# end hcpp-nodeapp
EOT
fi
# Notify installation has finished
/usr/local/hestia/bin/v-add-user-notification admin NodeApp "<span style=\"font-size:large;color:green;\">⬢</span> NodeApp plugin has finished installing."