@@ -32,15 +32,10 @@ echo_yellow() {
3232
3333# script info
3434echo_cyan " +----------------------------------------------------------------------
35- | MCSManager 安裝脚本 (MCSManager Installer)
35+ | MCSManager 安装脚本 (MCSManager Installer)
3636+----------------------------------------------------------------------
3737"
3838
39- web_install=true
40- if [[ -d " ${mcsmanager_install_path} " ]] && [[ ! -d " ${mcsmanager_install_path} /web" ]]; then
41- web_install=false
42- fi
43-
4439Red_Error () {
4540 echo ' ================================================='
4641 printf ' \033[1;31;40m%b\033[0m\n' " $@ "
@@ -62,7 +57,7 @@ Install_Node() {
6257
6358 rm -rf " node-$node -linux-$arch .tar.gz"
6459
65- # wget "https://nodejs.org/dist/$node/node-$node-linux-$arch.tar.gz" || Red_Error "[x] Failed to download node release"
60+ # wget "https://nodejs.org/dist/$node/node-$node-linux-$arch.tar.gz" || Red_Error "[x] Failed to download node release"
6661 wget " https://registry.npmmirror.com/-/binary/node/$node /node-$node -linux-$arch .tar.gz" || Red_Error " [x] Failed to download node release"
6762
6863 tar -zxf " node-$node -linux-$arch .tar.gz" || Red_Error " [x] Failed to untar node"
@@ -88,10 +83,6 @@ Install_Node() {
8883Install_MCSManager () {
8984 echo_cyan " [+] Install MCSManager..."
9085
91- if [ " $web_install " = false ]; then
92- echo_yellow " [-] will not install web... (The web folder was not found)"
93- fi
94-
9586 # stop service
9687 systemctl disable --now mcsm-{web,daemon}
9788
@@ -104,40 +95,15 @@ Install_MCSManager() {
10495 # cd /opt/mcsmanager
10596 cd " ${mcsmanager_install_path} " || Red_Error " [x] Failed to enter ${mcsmanager_install_path} "
10697
107- # backup data
108- if [ -d " ${mcsmanager_install_path} /daemon/data" ]; then
109- mkdir -p " $mcsmanager_install_path /temp/daemon"
110- cp -rf $mcsmanager_install_path /daemon/data/* $mcsmanager_install_path /temp/daemon
111- fi
112-
113- if [ -d " ${mcsmanager_install_path} /web/data" ]; then
114- mkdir -p " $mcsmanager_install_path /temp/web"
115- cp -rf $mcsmanager_install_path /web/data/* $mcsmanager_install_path /temp/web
116- fi
117-
11898 # download MCSManager release
11999 wget " ${mcsmanager_download_addr} " -O " ${package_name} " || Red_Error " [x] Failed to download MCSManager"
120100 tar -zxf ${package_name} -o || Red_Error " [x] Failed to untar ${package_name} "
121101 rm -rf " ${mcsmanager_install_path} /${package_name} "
122102
123103 # compatible with tar.gz packages of different formats
124- if [ -d " $mcsmanager_install_path /mcsmanager" ]; then
125- cp -rf $mcsmanager_install_path /mcsmanager/* $mcsmanager_install_path /
126- rm -rf $mcsmanager_install_path /mcsmanager
127- fi
128-
129- if [ -d " ${mcsmanager_install_path} /temp/daemon" ]; then
130- cp -rf $mcsmanager_install_path /temp/daemon/* $mcsmanager_install_path /daemon/data
131- rm -rf $mcsmanager_install_path /temp/daemon
132- fi
133-
134- if [ -d " ${mcsmanager_install_path} /temp/web" ]; then
135- cp -rf $mcsmanager_install_path /temp/web/* $mcsmanager_install_path /web/data
136- rm -rf $mcsmanager_install_path /temp/web
137- fi
138-
139- if [ -d " ${mcsmanager_install_path} /temp" ]; then
140- rm -rf $mcsmanager_install_path /temp
104+ if [ -d " /opt/mcsmanager/mcsmanager" ]; then
105+ cp -rf /opt/mcsmanager/mcsmanager/* /opt/mcsmanager/
106+ rm -rf /opt/mcsmanager/mcsmanager
141107 fi
142108
143109 # echo "[→] cd daemon"
@@ -146,22 +112,16 @@ Install_MCSManager() {
146112 echo_cyan " [+] Install MCSManager-Daemon dependencies..."
147113 env " $node_install_path " /bin/node " $node_install_path " /bin/npm install --registry=https://registry.npmmirror.com --production --no-fund --no-audit & > /dev/null || Red_Error " [x] Failed to npm install in ${mcsmanager_install_path} /daemon"
148114
149- if [ " $web_install " = true ]; then
150- # echo "[←] cd .."
151- cd " ${mcsmanager_install_path} /web" || Red_Error " [x] Failed to enter ${mcsmanager_install_path} /web"
115+ # echo "[←] cd .."
116+ cd " ${mcsmanager_install_path} /web" || Red_Error " [x] Failed to enter ${mcsmanager_install_path} /web"
152117
153- echo_cyan " [+] Install MCSManager-Web dependencies..."
154- env " $node_install_path " /bin/node " $node_install_path " /bin/npm install --production --no-fund --no-audit & > /dev/null || Red_Error " [x] Failed to npm install in ${mcsmanager_install_path} /web"
155- else
156- rm -rf " ${mcsmanager_install_path} /web"
157- fi
118+ echo_cyan " [+] Install MCSManager-Web dependencies..."
119+ env " $node_install_path " /bin/node " $node_install_path " /bin/npm install --registry=https://registry.npmmirror.com --production --no-fund --no-audit & > /dev/null || Red_Error " [x] Failed to npm install in ${mcsmanager_install_path} /web"
158120
159121 echo
160122 echo_yellow " =============== MCSManager ==============="
161123 echo_green " Daemon: ${mcsmanager_install_path} /daemon"
162- if [ " $web_install " = true ]; then
163- echo_green " Web: ${mcsmanager_install_path} /web"
164- fi
124+ echo_green " Web: ${mcsmanager_install_path} /web"
165125 echo_yellow " =============== MCSManager ==============="
166126 echo
167127 echo_green " [+] MCSManager installation success!"
@@ -188,8 +148,7 @@ Environment=\"PATH=${PATH}\"
188148WantedBy=multi-user.target
189149" > /etc/systemd/system/mcsm-daemon.service
190150
191- if [ " $web_install " = true ]; then
192- echo " [Unit]
151+ echo " [Unit]
193152Description=MCSManager-Web
194153
195154[Service]
@@ -202,14 +161,9 @@ Environment=\"PATH=${PATH}\"
202161[Install]
203162WantedBy=multi-user.target
204163" > /etc/systemd/system/mcsm-web.service
205- fi
206164
207165 systemctl daemon-reload
208- if [ " $web_install " = true ]; then
209- systemctl enable --now mcsm-{daemon,web}.service
210- else
211- systemctl enable --now mcsm-daemon.service
212- fi
166+ systemctl enable --now mcsm-{daemon,web}.service
213167 echo_green " Registered!"
214168
215169 sleep 2
@@ -219,31 +173,16 @@ WantedBy=multi-user.target
219173 echo_yellow " =================================================================="
220174 echo_green " 安装完成,欢迎使用 MCSManager !"
221175 echo_yellow " "
222- if [ " $web_install " = true ]; then
223- echo_cyan_n " 主控网页访问地址: "
224- echo_yellow " http://<Your IP>:23333 (Browser)"
225- fi
226-
176+ echo_cyan_n " 主控网页访问地址: "
177+ echo_yellow " http://<Your IP>:23333 (Browser)"
227178 echo_cyan_n " 被控守护进程地址: "
228179 echo_yellow " ws://<Your IP>:24444 (Cluster)"
229-
230- if [ " $web_install " = true ]; then
231- echo_red " 默认情况下,你必须开放\033[1;33m 23333 和 24444 \033[1;31m端口才能确保面板工作正常!"
232- else
233- echo_red " 默认情况下,你必须开放\033[1;33m 24444 \033[1;31m端口才能确保面板工作正常!"
234- fi
235-
180+ echo_red " 默认情况下,你必须开放 23333 和 24444 端口才能确保面板工作正常!"
236181 echo_yellow " "
237182 echo_cyan " 面板开关指令:"
238- if [ " $web_install " = true ]; then
239- echo_cyan " systemctl start mcsm-{daemon,web}.service"
240- echo_cyan " systemctl stop mcsm-{daemon,web}.service"
241- echo_cyan " systemctl restart mcsm-{daemon,web}.service"
242- else
243- echo_cyan " systemctl start mcsm-daemon.service"
244- echo_cyan " systemctl stop mcsm-daemon.service"
245- echo_cyan " systemctl restart mcsm-daemon.service"
246- fi
183+ echo_cyan " systemctl start mcsm-{daemon,web}.service"
184+ echo_cyan " systemctl stop mcsm-{daemon,web}.service"
185+ echo_cyan " systemctl restart mcsm-{daemon,web}.service"
247186 echo_yellow " "
248187 echo_green " 官方文档: https://docs.mcsmanager.com/"
249188 echo_yellow " =================================================================="
0 commit comments