forked from Matear890/gys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdddd.sh
97 lines (95 loc) · 3.17 KB
/
dddd.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
#!/usr/bin/env bash
##############################安装npm##############################
#node_modules路径
nodePath="/jd/scripts/node_modules"
echo -e "检测npm是否存在"
#判断panel文件夹是否存在,若不存在,复制/jd目录内
if [[ ! -d "$nodePath" ]]; then
echo "npm不存在."
npm install || npm install --registry=https://registry.npm.taobao.org
echo "npm已安装完成"
else
echo -e "npm存在...\n"
fi
##############################创建auth##############################
echo -e "开始检测auth.json文件是否存在"
authPath="/jd/config/auth.json"
if [[ ! -f "$authPath" ]]; then
echo "auth.json文件不存在"
cd /jd/config
touch auth.json
wget -q --no-check-certificate https://ghproxy.com/https://raw.githubusercontent.com/gys619/gys/main/auto.json -O auth.json.new
mv -f auth.json.new auth.json
echo "auth.json文件写入成功"
echo -e "auth.json文件创建成功\n"
else
echo -e "auth.json存在...\n"
fi
##############################安装面板 首先要把panel复制到config文件夹下##############################
#panel路径
echo -e "开始安装面板 "
PanelPath="/jd/panel"
#判断panel文件夹是否存在,若不存在,复制/jd目录内
if [[ ! -d "$PanelPath" ]]; then
echo "控制面板已和谐,重新拷贝面板目录..."
cp -r /jd/config/panel /jd/
echo -e "启动控制面板挂载程序..."
pm2 stop /jd/panel/server.js
pm2 start /jd/panel/server.js
else
echo -e "控制面板还存在...\n"
fi
##############################安装panel的npm##############################
#node_modules路径
pPath="/jd/panel/node_modules"
echo -e "开始安装panel的npm"
#判断panel文件夹是否存在,若不存在,复制/jd目录内
if [[ ! -d "$pPath" ]]; then
echo "npm不存在."
cd /jd/panel
npm install || npm install --registry=https://registry.npm.taobao.org
echo "npm已经装完"
echo -e "启动控制面板挂载程序...\n"
pm2 stop /jd/panel/ecosystem.config.js
pm2 start /jd/panel/ecosystem.config.js
else
echo -e "npm存在...\n"
fi
############################## 恢复HomePage ##############################
##panelDir=${ShellDir}/panel/public
echo -e "开始恢复HomePage"
cd /jd/panel/public
wget -q --no-check-certificate https://ghproxy.com/https://raw.githubusercontent.com/gys619/gys/main/home.html -O home.html.new
if [ $? -eq 0 ]; then
mv -f home.html.new home.html
echo -e "恢复 HomePage 成功!!!\n"
else
rm -rf home.html.new
echo -e "恢复 HomePage 失败...\n"
fi
echo -e "开始检测jpanel文件是都存在"
autoPath="/jd/jpanel.sh"
if [[ ! -f "$autoPath" ]]; then
echo "jpael.sh文件不存在"
cd /jd
touch jpanel.sh
wget -q --no-check-certificate https://ghproxy.com/https://raw.githubusercontent.com/gys619/gys/main/jpanel.sh -O jpanel.sh.new
mv -f jpanel.sh.new jpanel.sh
echo "jpanel.sh文件写入成功"
echo -e "jpanel.sh文件创建成功\n"
cd /jd
bash jpanel.sh
else
echo -e "jpanel.sh存在...\n"
fi
echo -e "检测面板是否运行"
PROC_NAME=server.js
ProcNumber=`ps -ef |grep -w $PROC_NAME|grep -v grep|wc -l`
if [ $ProcNumber -le 0 ];then
echo -e "面板进程没运行\n"
cd /jd
bash jpanel.sh
else
echo -e "面板进程运行中\n"
fi
exit 0