forked from miraai/NadekoBot-BashScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nadekopm2setup.sh
143 lines (128 loc) · 3.54 KB
/
nadekopm2setup.sh
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash -e
root=$(pwd)
echo ""
function detect_OS_ARCH_VER_BITS {
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
OS=Debian # XXX or Ubuntu??
VER=$(cat /etc/debian_version)
SVER=$( cat /etc/debian_version | grep -oP "[0-9]+" | head -1 )
elif [ -f /etc/centos-release ]; then
OS=CentOS
VER=$( cat /etc/centos-release | grep -oP "[0-9]+" | head -1 )
else
OS=$(uname -s)
VER=$(uname -r)
fi
case $(uname -m) in
x86_64)
BITS=64
;;
i*86)
BITS=32
;;
armv*)
BITS=32
;;
*)
BITS=?
;;
esac
case $(uname -m) in
x86_64)
ARCH=x64 # or AMD64 or Intel64 or whatever
;;
i*86)
ARCH=x86 # or IA32 or Intel32 or whatever
;;
*)
# leave ARCH as-is
;;
esac
}
declare OS ARCH VER BITS
detect_OS_ARCH_VER_BITS
export OS ARCH VER BITS
if [ "$BITS" = 32 ]; then
echo -e "Your system architecture is $ARCH which is unsupported to run Nadeko. \nYour OS: $OS \nOS Version: $VER"
echo
printf "\e[1;31mPlease check the NadekoBot self-hosting guide for alternatives.\e[0m\n"
rm nadekopm2setup.sh
exit 1
fi
echo -e "Welcome to NadekoBot's pm2 setup! \nWould you like to continue? \nYour OS: $OS \nOS Version: $VER \nArchitecture: $ARCH"
while true; do
read -p "[y/n]: " yn
case $yn in
[Yy]* ) clear; echo Running NadekoBot pm2 Setup; sleep 2; break;;
[Nn]* ) echo Quitting...; rm nadekopm2setup.sh && exit;;
* ) echo "Couldn't get that please type [y] for Yes or [n] for No.";;
esac
done
if [ "$OS" = "Ubuntu" ]; then
echo "This installer will download/update NodeJS/npm and install pm2."
echo ""
read -n 1 -s -p "Press any key to continue..."
echo ""
echo "Starting.."
echo "Installing node/npm. Please wait.."
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential
sudo npm i -g npm
echo "Installing pm2..."
sudo npm install pm2@3.1.3 -g
fi
if [ "$OS" = "Debian" ]; then
echo "This installer will download/update NodeJS/npm and install pm2."
echo ""
read -n 1 -s -p "Press any key to continue..."
echo ""
echo "Starting.."
echo "Installing node/npm. Please wait.."
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential
sudo npm i -g npm
echo "Installing pm2..."
sudo npm install pm2@3.1.3 -g
fi
if [ "$OS" = "LinuxMint" ]; then
echo "This installer will download/update NodeJS/npm and install pm2."
echo ""
read -n 1 -s -p "Press any key to continue..."
echo ""
echo "Starting.."
echo "Installing node/npm. Please wait.."
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential
sudo npm i -g npm
echo "Installing pm2..."
sudo npm install pm2@3.1.3 -g
fi
if [ "$OS" = "CentOS" ]; then
echo "This installer will download/update NodeJS/npm and install pm2."
echo ""
read -n 1 -s -p "Press any key to continue..."
echo ""
echo "Starting.."
echo "Installing node/npm. Please wait.."
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
sudo yum -y install nodejs
sudo yum install gcc-c++ make
sudo npm i -g npm
echo "Installing pm2..."
sudo npm install pm2@3.1.3 -g
fi
echo
echo "NadekoBot pm2 Installation completed..."
read -n 1 -s -p "Press any key to continue to the main menu..."
sleep 2
cd "$root"
rm "$root/nadekopm2setup.sh"
exit 0