forked from MCSManager/Script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_bak.sh
More file actions
226 lines (177 loc) · 6.59 KB
/
setup_bak.sh
File metadata and controls
226 lines (177 loc) · 6.59 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/bash
printf "\033c"
arch=$(uname -m)
mcsmanager_install_path="/opt/mcsmanager"
Red_Error() {
echo '================================================='
printf '\033[1;31;40m%b\033[0m\n' "$@"
echo '================================================='
exit 1
}
Install_Node() {
node_install_path="/opt/node-v14.19.1-linux-${arch}"
echo "[x] rm -irf ${node_install_path}"
rm -irf ${node_install_path}
echo "[→] cd /opt || exit"
cd /opt || exit
echo "[↓] wget https://npmmirror.com/mirrors/node/v14.19.1/node-v14.19.1-linux-${arch}.tar.gz"
wget https://npmmirror.com/mirrors/node/v14.19.1/node-v14.19.1-linux-${arch}.tar.gz
echo "[↑] tar -zxf node-v14.19.1-linux-${arch}.tar.gz"
tar -zxf node-v14.19.1-linux-${arch}.tar.gz
echo "[x] rm -rf node-v14.19.1-linux-${arch}.tar.gz"
rm -rf node-v14.19.1-linux-${arch}.tar.gz
#echo "[x] Delete the original Node link"
#rm -f /usr/bin/npm
#rm -f /usr/bin/node
#rm -f /usr/local/bin/npm
#rm -f /usr/local/bin/node
#echo "[+] Creating a Node link"
#ln -s ${node_install_path}/bin/npm /usr/bin/
#ln -s ${node_install_path}/bin/node /usr/bin/
#ln -s ${node_install_path}/bin/npm /usr/local/bin/
#ln -s ${node_install_path}/bin/node /usr/local/bin/
echo "=============== Node Version ==============="
echo " node: $(${node_install_path}/bin/node -v)"
#echo " npm: $(${node_install_path}/bin/npm -v)"
echo "=============== Node Version ==============="
echo
echo "[-] Node Installed Successfully!"
echo
sleep 3
}
Install_MCSManager() {
echo "[x] Delete the original MCSManager"
rm -irf ${mcsmanager_install_path}
echo "[+] mkdir -p ${mcsmanager_install_path}"
mkdir -p ${mcsmanager_install_path} || exit
echo "[→] cd ${mcsmanager_install_path}"
cd ${mcsmanager_install_path} || exit
echo "[↓] git clone https://gitee.com/mcsmanager/MCSManager-Daemon-Production.git"
git clone https://gitee.com/mcsmanager/MCSManager-Daemon-Production.git
echo "[-] mv MCSManager-Daemon-Production daemon"
mv MCSManager-Daemon-Production daemon
echo "[→] cd daemon"
cd daemon || exit
echo "[+] npm install --registry=https://registry.npmmirror.com"
/usr/bin/env ${node_install_path}/bin/node ${node_install_path}/bin/npm install --registry=https://registry.npmmirror.com
echo "[←] cd .."
cd ..
echo "[↓] git clone https://gitee.com/mcsmanager/MCSManager-Web-Production.git"
git clone https://gitee.com/mcsmanager/MCSManager-Web-Production.git
echo "[-] mv MCSManager-Web-Production web"
mv MCSManager-Web-Production web
echo "[→] cd web"
cd web || exit
echo "[+] npm install --registry=https://registry.npmmirror.com"
/usr/bin/env ${node_install_path}/bin/node ${node_install_path}/bin/npm install --registry=https://registry.npmmirror.com
echo "=============== MCSManager ==============="
echo " Daemon: ${mcsmanager_install_path}/daemon"
echo " Web: ${mcsmanager_install_path}/web"
echo "=============== MCSManager ==============="
echo
echo ""
echo -e "\033[1;32m[ok] MCSManager installed successfully!!!\033[0m"
echo "[ok] Location: ${mcsmanager_install_path}"
echo
sleep 3
}
Create_Service() {
echo "[x] Initialize the service file"
rm -f /etc/systemd/system/mcsm-daemon.service
rm -f /etc/systemd/system/mcsm-web.service
echo "[+] creating >>/etc/systemd/system/mcsm-daemon.service"
echo "
[Unit]
Description=MCSManager Daemon
[Service]
WorkingDirectory=/opt/mcsmanager/daemon
ExecStart=${node_install_path}/bin/node app.js
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
[Install]
WantedBy=multi-user.target
" > /etc/systemd/system/mcsm-daemon.service
echo "[+] creating >>/etc/systemd/system/mcsm-web.service"
echo "
[Unit]
Description=MCSManager Web
[Service]
WorkingDirectory=/opt/mcsmanager/web
ExecStart=${node_install_path}/bin/node app.js
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
[Install]
WantedBy=multi-user.target
" > /etc/systemd/system/mcsm-web.service
echo "[-] systemctl daemon-reload"
systemctl daemon-reload
echo "[+] systemctl enable mcsm-daemon.service --now"
systemctl enable mcsm-daemon.service --now
echo "[+] systemctl enable mcsm-web.service --now"
systemctl enable mcsm-web.service --now
sleep 4
echo "=================================================================="
echo -e "\033[1;32mWelcome to MCSManager\033[0m"
echo "=================================================================="
echo "Web Service Address: http://localhost:23333"
echo "Daemon Service Address: http://localhost:24444"
echo "Username: root"
echo "Password: 123456"
echo -e "\033[33mYou must expose ports 23333 and 24444 to use the service properly on the Internet.\033[0m"
echo "=================================================================="
echo "systemctl restart mcsm-{daemon,web}.service"
echo "systemctl disable mcsm-{daemon,web}.service"
echo "systemctl enable mcsm-{daemon,web}.service"
echo "systemctl start mcsm-{daemon,web}.service"
echo "systemctl stop mcsm-{daemon,web}.service"
echo "=================================================================="
}
# ----------------- Program start -----------------
# rm -f "$0"
if [ $(whoami) != "root" ]; then
Red_Error "[x] Please use Root!"
fi
# Config Architecture
if [[ $arch == x86_64 ]] || [[ $arch == aarch64 ]] || [[ $arch == ppc64le ]] || [[ $arch == s390x ]] || [[ $arch == arm ]]; then
if [ $arch == x86_64 ]; then
arch=x64
echo "x64 architecture detected"
fi
if [ $arch == aarch64 ]; then
arch=arm64
echo "64-bit ARM architecture detected"
fi
if [ $arch == arm ]; then
arch=armv7l
echo "32-bit ARM architecture detected"
fi
if [ $arch == ppc64le ]; then
echo "IBM POWER architecture detected"
fi
if [ $arch == s390x ]; then
echo "IBM LinuxONE architecture detected"
fi
else
Red_Error "[x] Sorry, this architecture is not supported yet!"
fi
# Check 64-bit
#is64bit=$(getconf LONG_BIT)
#if [ "${is64bit}" != '64' ]; then
# Red_Error "[x] Please use 64-bit system!"
#fi
echo "+----------------------------------------------------------------------
| MCSManager Installer
+----------------------------------------------------------------------
| Copyright © 2022 Suwings All rights reserved.
+----------------------------------------------------------------------
| Shell Install Script by Nuomiaa & CreeperKong
+----------------------------------------------------------------------
"
echo "[+] Installing dependent software... (git,tar)"
yum install -y git tar
apt install -y git tar
pacman -Syu --noconfirm git tar
zypper --non-interactive install git tar
Install_Node
Install_MCSManager
Create_Service