BG5 commited on
Commit
b2242cf
·
verified ·
1 Parent(s): c55030e

Upload install.sh

Browse files
Files changed (1) hide show
  1. install.sh +1648 -0
install.sh ADDED
@@ -0,0 +1,1648 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
3
+ export PATH
4
+ LANG=en_US.UTF-8
5
+
6
+ INSTALL_LOGFILE="/tmp/btpanel-install.log"
7
+ if [ -f "$INSTALL_LOGFILE" ];then
8
+ rm -f $INSTALL_LOGFILE
9
+ fi
10
+ exec > >(tee -a "$INSTALL_LOGFILE") 2>&1
11
+
12
+ CURL_CHECK=$(which curl)
13
+ if [ "$?" == "0" ];then
14
+ curl -sS --connect-timeout 10 -m 10 https://www.bt.cn/api/wpanel/SetupCount > /dev/null 2>&1
15
+ else
16
+ wget -O /dev/null -o /dev/null -T 5 https://www.bt.cn/api/wpanel/SetupCount
17
+ fi
18
+
19
+ signal_type=""
20
+ exit_msg() {
21
+ case $signal_type in
22
+ SIGINT)
23
+ EXIT_MSG="捕获到Ctrl+C信号退出"
24
+ ;;
25
+ SIGTERM)
26
+ EXIT_MSG="捕获到进程被杀死"
27
+ ;;
28
+ SIGHUP)
29
+ EXIT_MSG="捕获到终端连接异常"
30
+ ;;
31
+ *)
32
+ EXIT_MSG="未知信号"
33
+ ;;
34
+ esac
35
+
36
+ local TIME=$(date "+%Y-%m-%d %H:%M:%S")
37
+ if [ -s "/etc/redhat-release" ];then
38
+ SYS_VERSION=$(cat /etc/redhat-release)
39
+ elif [ -s "/etc/issue" ]; then
40
+ SYS_VERSION=$(cat /etc/issue)
41
+ fi
42
+ SYS_INFO=$(uname -a)
43
+ SYS_BIT=$(getconf LONG_BIT)
44
+ MEM_TOTAL=$(free -m|grep Mem|awk '{print $2}')
45
+ CPU_INFO=$(getconf _NPROCESSORS_ONLN)
46
+
47
+ curl -sS --connect-timeout 3 -m 3 --request POST \
48
+ --url "http://api.bt.cn/bt_error/index.php" \
49
+ --data "UID=89045" \
50
+ --data "PANEL_VERSION=9.3.9"\
51
+ --data "REQUEST_DATE=${TIME}" \
52
+ --data "OS_VERSION=${SYS_VERSION}" \
53
+ --data "REMOTE_ADDR=192.168.168.1641" \
54
+ --data "REQUEST_URI=panel" \
55
+ --data "USER_AGENT=${SYS_INFO}" \
56
+ --data "ERROR_INFO=${EXIT_MSG}" \
57
+ --data "PACK_TIME=${TIME}" \
58
+ --data "TYPE=3" > /dev/null
59
+ exit 1
60
+ }
61
+
62
+ trap 'signal_type=SIGINT; exit_msg' SIGINT
63
+ trap 'signal_type=SIGTERM; exit_msg' SIGTERM
64
+ trap 'signal_type=SIGHUP; exit_msg' SIGHUP
65
+
66
+
67
+ if [ $(whoami) != "root" ];then
68
+ if [ -f "/usr/bin/curl" ];then
69
+ DOWN_EXEC="curl -sSO"
70
+ else
71
+ DOWN_EXEC="wget -O install_panel.sh"
72
+ fi
73
+
74
+ echo "====================================================="
75
+ echo "检查到当前非root权限进行面板安装"
76
+ IS_UBUNTU=$(cat /etc/issue|grep Ubuntu)
77
+ IS_DEBIAN=$(cat /etc/issue|grep Debian)
78
+ if [ "${IS_UBUNTU}" ];then
79
+ echo "请使用下面命令重新执行安装面板"
80
+ echo "sudo $DOWN_EXEC https://download.bt.cn/install/install_panel.sh;sudo bash install_panel.sh"
81
+ elif [ "${IS_DEBIAN}" ];then
82
+ echo "请执行su root命令切换为root账户后"
83
+ echo "执行下面命令重新安装宝塔面板"
84
+ echo "$DOWN_EXEC https://download.bt.cn/install/install_panel.sh;bash install_panel.sh"
85
+ else
86
+ if [ -f "/usr/bin/sudo" ];then
87
+ echo "请使用下面命令使用root权限重新执行安装"
88
+ echo "sudo $DOWN_EXEC https://download.bt.cn/install/install_panel.sh;sudo bash install_panel.sh"
89
+ else
90
+ echo "请执行su root命令切换为root账户后"
91
+ echo "执行下面命令重新安装宝塔面板"
92
+ echo "$DOWN_EXEC https://download.bt.cn/install/install_panel.sh;bash install_panel.sh"
93
+ fi
94
+ fi
95
+
96
+ echo "-----------------------------------------------------"
97
+ exit 1
98
+ fi
99
+
100
+
101
+ is64bit=$(getconf LONG_BIT)
102
+ if [ "${is64bit}" != '64' ];then
103
+ echo "抱歉, 当前面板版本不支持32位系统, 请使用64位系统或安装宝塔5.9!";
104
+ exit 1
105
+ fi
106
+
107
+ Centos6Check=$(cat /etc/redhat-release | grep ' 6.' | grep -iE 'centos|Red Hat')
108
+ if [ "${Centos6Check}" ];then
109
+ echo "Centos6不支持安装宝塔面板,请更换Centos7/8安装宝塔面板"
110
+ exit 1
111
+ fi
112
+
113
+ UbuntuCheck=$(cat /etc/issue|grep Ubuntu|awk '{print $2}'|cut -f 1 -d '.')
114
+ if [ "${UbuntuCheck}" ] && [ "${UbuntuCheck}" -lt "16" ];then
115
+ echo "Ubuntu ${UbuntuCheck}不支持安装宝塔面板,建议更换Ubuntu18/20安装宝塔面板"
116
+ exit 1
117
+ fi
118
+ HOSTNAME_CHECK=$(cat /etc/hostname)
119
+ if [ -z "${HOSTNAME_CHECK}" ];then
120
+ echo "localhost" > /etc/hostname
121
+ # echo "当前主机名hostname为空无法安装宝塔面板,请咨询服务器运营商设置好hostname后再重新安装"
122
+ # exit 1
123
+ fi
124
+
125
+ UBUNTU_NO_LTS=$(cat /etc/issue|grep Ubuntu|grep -E "19|21|23|25")
126
+ if [ "${UBUNTU_NO_LTS}" ];then
127
+ echo "当前您使用的非Ubuntu-lts版本,无法进行宝塔面板的安装"
128
+ echo "请使用Ubuntu-20/20/22/24进行安装宝塔面板"
129
+ exit 1
130
+ fi
131
+
132
+ DEBIAN_9_C=$(cat /etc/issue|grep Debian|grep -E "8 |9 ")
133
+ if [ "${DEBIAN_9_C}" ];then
134
+ echo "当前您使用的Debian-8/9,官方已经停止支持、无法进行宝塔面板的安装"
135
+ echo "请使用Debian-11/12进行安装宝塔面板"
136
+ exit 1
137
+ fi
138
+
139
+ cd ~
140
+ setup_path="/www"
141
+ python_bin=$setup_path/server/panel/pyenv/bin/python
142
+ cpu_cpunt=$(cat /proc/cpuinfo|grep processor|wc -l)
143
+ panelPort=7860
144
+ # if [ "$1" ];then
145
+ # IDC_CODE=$1
146
+ # fi
147
+
148
+ Ready_Check(){
149
+ WWW_DISK_SPACE=$(df |grep /www|awk '{print $4}')
150
+ ROOT_DISK_SPACE=$(df |grep /$|awk '{print $4}')
151
+
152
+ if [ "${ROOT_DISK_SPACE}" -le 412000 ];then
153
+ df -h
154
+ echo -e "系统盘剩余空间不足400M 无法继续安装宝塔面板!"
155
+ echo -e "请尝试清理磁盘空间后再重新进行安装"
156
+ exit 1
157
+ fi
158
+ if [ "${WWW_DISK_SPACE}" ] && [ "${WWW_DISK_SPACE}" -le 412000 ] ;then
159
+ echo -e "/www盘剩余空间不足400M 无法继续安装宝塔面板!"
160
+ echo -e "请尝试清理磁盘空间后再重新进行安装"
161
+ exit 1
162
+ fi
163
+
164
+ # ROOT_DISK_INODE=$(df -i|grep /$|awk '{print $2}')
165
+ # if [ "${ROOT_DISK_INODE}" != "0" ];then
166
+ # ROOT_DISK_INODE_FREE=$(df -i|grep /$|awk '{print $4}')
167
+ # if [ "${ROOT_DISK_INODE_FREE}" -le 1000 ];then
168
+ # echo -e "系统盘剩余inodes空间不足1000,无法继续安装!"
169
+ # echo -e "请尝试清理磁盘空间后再重新进行安装"
170
+ # exit 1
171
+ # fi
172
+ # fi
173
+
174
+ # WWW_DISK_INODE==$(df -i|grep /www|awk '{print $2}')
175
+ # if [ "${WWW_DISK_INODE}" ] && [ "${WWW_DISK_INODE}" != "0" ] ;then
176
+ # WWW_DISK_INODE_FREE=$(df -i|grep /www|awk '{print $4}')
177
+ # if [ "${WWW_DISK_INODE_FREE}" ] && [ "${WWW_DISK_INODE_FREE}" -le 1000 ] ;then
178
+ # echo -e "/www盘剩余inodes空间不足1000, 无法继续安装!"
179
+ # echo -e "请尝试清理磁盘空间后再重新进行安装"
180
+ # exit 1
181
+ # fi
182
+ # fi
183
+ }
184
+
185
+ GetSysInfo(){
186
+ if [ -s "/etc/redhat-release" ];then
187
+ SYS_VERSION=$(cat /etc/redhat-release)
188
+ elif [ -s "/etc/issue" ]; then
189
+ SYS_VERSION=$(cat /etc/issue)
190
+ fi
191
+ SYS_INFO=$(uname -a)
192
+ SYS_BIT=$(getconf LONG_BIT)
193
+ MEM_TOTAL=$(free -m|grep Mem|awk '{print $2}')
194
+ CPU_INFO=$(getconf _NPROCESSORS_ONLN)
195
+
196
+ echo -e ${SYS_VERSION}
197
+ echo -e Bit:${SYS_BIT} Mem:${MEM_TOTAL}M Core:${CPU_INFO}
198
+ echo -e ${SYS_INFO}
199
+ echo -e "============================================"
200
+ echo -e "请截图以上报错信息发帖至论坛www.bt.cn/bbs求助"
201
+ echo -e "或添加QQ群:706478424 寻求帮助"
202
+ echo -e "============================================"
203
+
204
+ if [ -f "/etc/redhat-release" ];then
205
+ Centos7Check=$(cat /etc/redhat-release | grep ' 7.' | grep -iE 'centos')
206
+ echo -e "============================================"
207
+ echo -e "Centos7/8官方已经停止支持"
208
+ echo -e "如是新安装系统服务器建议更换至Debian-12/Ubuntu-22/Centos-9系统安装宝塔面板"
209
+ echo -e "============================================"
210
+ fi
211
+
212
+
213
+ if [ -f "/usr/sbin/setstatus" ] || [ -f "/usr/sbin/setstatus" ];then
214
+ echo -e "=================================================="
215
+ echo -e " 检测到为麒麟系统,可能默认开启安全功能导致安装失败"
216
+ echo -e " 请执行以下命令关闭安全加固后,再重新安装宝塔面板看是否正常"
217
+ echo -e " 命令:sudo setstatus softmode -p"
218
+ echo -e "=================================================="
219
+ fi
220
+
221
+ SYS_SSL_LIBS=$(pkg-config --list-all | grep -q libssl)
222
+ if [ -z "$SYS_SSL_LIBS" ];then
223
+ echo "检测到缺少系统ssl相关依赖,可执行下面命令安装依赖后再重新安装宝塔看是否正常"
224
+ echo "执行前请确保系统源正常"
225
+ if [ -f "/usr/bin/yum" ];then
226
+ echo "安装依赖命令: yum install openssl-devel -y"
227
+ elif [ -f "/usr/bin/apt-get" ];then
228
+ echo "安装依赖命令: apt-get install libssl-dev -y"
229
+ fi
230
+ rm -rf /www/server/panel/pyenv
231
+ echo -e "=================================================="
232
+ fi
233
+
234
+ if [ -f "/tmp/btpanel-install.log" ] && [ ! -f "/tmp/btpanel_err.pl" ];then
235
+ local TIME=$(date "+%Y-%m-%d %H:%M:%S")
236
+ INSTALL_USER=$(whoami)
237
+ echo -e Bit:${SYS_BIT} Mem:${MEM_TOTAL}M Core:${CPU_INFO} >> ${INSTALL_LOGFILE}
238
+ echo -e ${SYS_VERSION} ${SYS_INFO} >> ${INSTALL_LOGFILE}
239
+ echo -e $INSTALL_USER >> ${INSTALL_LOGFILE}
240
+ OS_INFO=$(cat /etc/os-release |grep ID)
241
+ echo $OS_INFO >> $INSTALL_LOGFILE
242
+ PANEL_PORT_CHECK=$(lsof -i :${panelPort})
243
+ echo ${PANEL_PORT_CHECK} >> $INSTALL_LOGFILE
244
+ echo $LOCAL_CURL >> $INSTALL_LOGFILE
245
+ ERR_MSG=$(tail -n 50 $INSTALL_LOGFILE)
246
+ is_aarch64=$(uname -a|grep aarch64)
247
+ if [ "${is_aarch64}" ];then
248
+ PANEL_V="9.5.0"
249
+ else
250
+ PANEL_V="9.4.9"
251
+ fi
252
+ curl -sS --connect-timeout 3 -m 3 --request POST \
253
+ --url "http://api.bt.cn/bt_error/index.php" \
254
+ --data "UID=89045" \
255
+ --data "PANEL_VERSION=${PANEL_V}"\
256
+ --data "REQUEST_DATE=${TIME}" \
257
+ --data "OS_VERSION=${SYS_VERSION}" \
258
+ --data "REMOTE_ADDR=192.168.168.1641" \
259
+ --data "REQUEST_URI=panel" \
260
+ --data "USER_AGENT=${SYS_INFO}" \
261
+ --data "ERROR_INFO=${ERR_MSG}" \
262
+ --data "PACK_TIME=${TIME}" \
263
+ --data "TYPE=3" > /dev/null
264
+ fi
265
+ echo "True" > /tmp/btpanel_err.pl
266
+ # if [ -f "/usr/bin/qrencode" ];then
267
+ # echo -e "或微信扫码联系企业微信技术求助"
268
+ # echo -e "============================================"
269
+ # qrencode -t ANSIUTF8 "https://work.weixin.qq.com/kfid/kfc9072f0e29a53bd52"
270
+ # echo -e "============================================"
271
+ # else
272
+ # echo -e "或手机访问以下链接、扫码联系企业微信技术求助"
273
+ # echo -e "============================================"
274
+ # echo -e "联系链接:https://work.weixin.qq.com/kfid/kfc9072f0e29a53bd52"
275
+ # echo -e "============================================"
276
+ # fi
277
+ }
278
+ Red_Error(){
279
+ echo '=================================================';
280
+ printf '\033[1;31;40m%b\033[0m\n' "$@";
281
+ GetSysInfo
282
+ exit 1;
283
+ }
284
+ Lock_Clear(){
285
+ if [ -f "/etc/bt_crack.pl" ];then
286
+ chattr -R -ia /www
287
+ chattr -ia /etc/init.d/bt
288
+ \cp -rpa /www/backup/panel/vhost/* /www/server/panel/vhost/
289
+ mv /www/server/panel/BTPanel/__init__.bak /www/server/panel/BTPanel/__init__.py
290
+ rm -f /etc/bt_crack.pl
291
+ fi
292
+ }
293
+ Install_Check(){
294
+ if [ "${INSTALL_FORCE}" ];then
295
+ return
296
+ fi
297
+ echo -e "----------------------------------------------------"
298
+ echo -e "检查已有其他Web/mysql环境,安装宝塔可能影响现有站点及数据"
299
+ echo -e "Web/mysql service is alreday installed,Can't install panel"
300
+ echo -e "----------------------------------------------------"
301
+ echo -e "已知风险/Enter yes to force installation"
302
+ yes="yes"
303
+ if [ "$yes" != "yes" ];then
304
+ echo -e "------------"
305
+ echo "取消安装"
306
+ exit;
307
+ fi
308
+ INSTALL_FORCE="true"
309
+ }
310
+ System_Check(){
311
+ MYSQLD_CHECK=$(ps -ef |grep mysqld|grep -v grep|grep -v /www/server/mysql)
312
+ PHP_CHECK=$(ps -ef|grep php-fpm|grep master|grep -v /www/server/php)
313
+ NGINX_CHECK=$(ps -ef|grep nginx|grep master|grep -v /www/server/nginx)
314
+ HTTPD_CHECK=$(ps -ef |grep -E 'httpd|apache'|grep -v /www/server/apache|grep -v grep)
315
+ if [ "${PHP_CHECK}" ] || [ "${MYSQLD_CHECK}" ] || [ "${NGINX_CHECK}" ] || [ "${HTTPD_CHECK}" ];then
316
+ Install_Check
317
+ fi
318
+ }
319
+ Set_Ssl(){
320
+ SET_SSL=true
321
+ if [ "${SSL_PL}" ];then
322
+ SET_SSL=""
323
+ fi
324
+ }
325
+ Add_lib_Install(){
326
+ if [ -f "/etc/os-release" ];then
327
+ . /etc/os-release
328
+ OS_V=${VERSION_ID%%.*}
329
+ if [ "${ID}" == "debian" ] && [[ "${OS_V}" =~ ^(11|12)$ ]];then
330
+ OS_NAME=${ID}
331
+ elif [ "${ID}" == "ubuntu" ] && [[ "${OS_V}" =~ ^(22|24)$ ]];then
332
+ OS_NAME=${ID}
333
+ elif [ "${ID}" == "centos" ] && [[ "${OS_V}" =~ ^(7)$ ]];then
334
+ OS_NAME="el"
335
+ elif [ "${ID}" == "opencloudos" ] && [[ "${OS_V}" =~ ^(9)$ ]];then
336
+ OS_NAME=${ID}
337
+ elif [ "${ID}" == "tencentos" ] && [[ "${OS_V}" =~ ^(4)$ ]];then
338
+ OS_NAME=${ID}
339
+ elif [ "${ID}" == "hce" ] && [[ "${OS_V}" =~ ^(2)$ ]];then
340
+ OS_NAME=${ID}
341
+ elif { [ "${ID}" == "almalinux" ] || [ "${ID}" == "centos" ] || [ "${ID}" == "rocky" ]; } && [[ "${OS_V}" =~ ^(9)$ ]]; then
342
+ OS_NAME="el"
343
+ fi
344
+ fi
345
+
346
+ X86_CHECK=$(uname -m|grep x86_64)
347
+
348
+ if [ "${OS_NAME}" ] && [ "${X86_CHECK}" ];then
349
+ if [ "${PM}" = "yum" ]; then
350
+ mtype="1"
351
+ elif [ "${PM}" = "apt-get" ]; then
352
+ mtype="4"
353
+ fi
354
+ cd /www/server/panel/class
355
+ btpython -c "import panelPlugin; plugin = panelPlugin.panelPlugin(); plugin.check_install_lib('${mtype}')"
356
+ echo "True" > /tmp/panelTask.pl
357
+ echo "True" > /www/server/panel/install/ins_lib.pl
358
+ fi
359
+ }
360
+ Get_Pack_Manager(){
361
+ if [ -f "/usr/bin/yum" ] && [ -d "/etc/yum.repos.d" ]; then
362
+ PM="yum"
363
+ elif [ -f "/usr/bin/apt-get" ] && [ -f "/usr/bin/dpkg" ]; then
364
+ PM="apt-get"
365
+ fi
366
+ }
367
+ Set_Repo_Url(){
368
+ if [ "${PM}"="apt-get" ];then
369
+ ALI_CLOUD_CHECK=$(grep Alibaba /etc/motd)
370
+ Tencent_Cloud=$(cat /etc/hostname |grep -E VM-[0-9]+-[0-9]+)
371
+ if [ "${ALI_CLOUD_CHECK}" ] || [ "${Tencent_Cloud}" ];then
372
+ return
373
+ fi
374
+
375
+ CN_CHECK=$(curl -sS --connect-timeout 10 -m 10 https://api.bt.cn/api/isCN)
376
+ if [ "${CN_CHECK}" == "True" ];then
377
+ SOURCE_URL_CHECK=$(grep -E 'security.ubuntu.com|archive.ubuntu.com|security.debian.org|deb.debian.org' /etc/apt/sources.list)
378
+ # if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ];then
379
+ # SOURCE_URL_CHECK=$(grep -E 'security.ubuntu.com|archive.ubuntu.com|security.debian.org|deb.debian.org' /etc/apt/sources.list.d/ubuntu.sources)
380
+ # fi
381
+ fi
382
+
383
+ #GET_SOURCES_URL=$(cat /etc/apt/sources.list|grep ^deb|head -n 1|awk -F[/:] '{print $4}')
384
+ GET_SOURCES_URL=$(cat /etc/apt/sources.list|grep ^deb|head -n 1|sed -E 's|^[^ ]+ https?://([^/]+).*|\1|')
385
+ # if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ];then
386
+ # GET_SOURCES_URL=$(cat /etc/apt/sources.list.d/ubuntu.sources|grep URIs:|head -n 1|sed -E 's|^[^ ]+ https?://([^/]+).*|\1|')
387
+ # fi
388
+ NODE_CHECK=$(curl --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${GET_SOURCES_URL} -o /dev/null)
389
+ NODE_STATUS=$(echo ${NODE_CHECK}|awk '{print $1}')
390
+ TIME_TOTAL=$(echo ${NODE_CHECK}|awk '{print $2 * 1000}'|cut -d '.' -f 1)
391
+
392
+ if { [ "${NODE_STATUS}" != "200" ] && [ "${NODE_STATUS}" != "301" ]; } || [ "${TIME_TOTAL}" -ge "150" ] || [ "${SOURCE_URL_CHECK}" ]; then
393
+ \cp -rpa /etc/apt/sources.list /etc/apt/sources.list.btbackup
394
+ apt_lists=(mirrors.cloud.tencent.com mirrors.163.com repo.huaweicloud.com mirrors.tuna.tsinghua.edu.cn mirrors.aliyun.com mirrors.ustc.edu.cn )
395
+ for list in ${apt_lists[@]};
396
+ do
397
+ NODE_CHECK=$(curl --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${list} -o /dev/null)
398
+ NODE_STATUS=$(echo ${NODE_CHECK}|awk '{print $1}')
399
+ TIME_TOTAL=$(echo ${NODE_CHECK}|awk '{print $2 * 1000}'|cut -d '.' -f 1)
400
+ if [ "${NODE_STATUS}" == "200" ] || [ "${NODE_STATUS}" == "301" ];then
401
+ if [ "${TIME_TOTAL}" -le "150" ];then
402
+ if [ -f "/etc/apt/sources.list" ];then
403
+ sed -i "s/${GET_SOURCES_URL}/${list}/g" /etc/apt/sources.list
404
+ sed -i "s/cn.security.ubuntu.com/${list}/g" /etc/apt/sources.list
405
+ sed -i "s/cn.archive.ubuntu.com/${list}/g" /etc/apt/sources.list
406
+ sed -i "s/security.ubuntu.com/${list}/g" /etc/apt/sources.list
407
+ sed -i "s/archive.ubuntu.com/${list}/g" /etc/apt/sources.list
408
+ sed -i "s/security.debian.org/${list}/g" /etc/apt/sources.list
409
+ sed -i "s/deb.debian.org/${list}/g" /etc/apt/sources.list
410
+ fi
411
+ # if [ -f "/etc/apt/sources.list.d/ubuntu.sources" ];then
412
+ # \cp -rpa /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak
413
+ # sed -i "s/${GET_SOURCES_URL}/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
414
+ # sed -i "s/cn.security.ubuntu.com/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
415
+ # sed -i "s/cn.archive.ubuntu.com/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
416
+ # sed -i "s/security.ubuntu.com/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
417
+ # sed -i "s/archive.ubuntu.com/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
418
+ # sed -i "s/security.debian.org/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
419
+ # sed -i "s/deb.debian.org/${list}/g" /etc/apt/sources.list.d/ubuntu.sources
420
+ # fi
421
+ break;
422
+ fi
423
+ fi
424
+ done
425
+ fi
426
+ fi
427
+ }
428
+ Auto_Swap()
429
+ {
430
+ swap=$(free |grep Swap|awk '{print $2}')
431
+ if [ "${swap}" -gt 1 ];then
432
+ echo "Swap total sizse: $swap";
433
+ return;
434
+ fi
435
+ if [ ! -d /www ];then
436
+ mkdir /www
437
+ fi
438
+ echo "正在设置虚拟内存,请稍等..........";
439
+ echo '---------------------------------------------';
440
+ swapFile="/www/swap"
441
+ dd if=/dev/zero of=$swapFile bs=1M count=1025
442
+ mkswap -f $swapFile
443
+ swapon $swapFile
444
+ echo "$swapFile swap swap defaults 0 0" >> /etc/fstab
445
+ swap=`free |grep Swap|awk '{print $2}'`
446
+ if [ $swap -gt 1 ];then
447
+ KERNEL_MAJOR_VERSION=$(uname -r | cut -d '-' -f1 | awk -F. '{print $1}')
448
+ KERNEL_MINOR_VERSION=$(uname -r | cut -d '-' -f1 | awk -F. '{print $2}')
449
+ if [ -f "/etc/sysctl.conf" ]; then
450
+ sed -i "/vm.swappiness/d" /etc/sysctl.conf
451
+ fi
452
+ if [ "$KERNEL_MAJOR_VERSION" -lt 3 ]; then
453
+ sysctl -w vm.swappiness=1
454
+ echo "vm.swappiness=1" >> /etc/sysctl.conf
455
+ elif [ "$KERNEL_MAJOR_VERSION" = "3" ] && [ "$KERNEL_MINOR_VERSION" -lt 5 ]; then
456
+ sysctl -w vm.swappiness=1
457
+ echo "vm.swappiness=1" >> /etc/sysctl.conf
458
+ else
459
+ sysctl -w vm.swappiness=0
460
+ echo "vm.swappiness=0" >> /etc/sysctl.conf
461
+ fi
462
+ echo "Swap total sizse: $swap";
463
+ return;
464
+ fi
465
+
466
+ sed -i "/\/www\/swap/d" /etc/fstab
467
+ rm -f $swapFile
468
+ }
469
+ Service_Add(){
470
+ if [ "${PM}" == "yum" ] || [ "${PM}" == "dnf" ]; then
471
+ chkconfig --add bt
472
+ chkconfig --level 2345 bt on
473
+ Centos9Check=$(cat /etc/redhat-release |grep ' 9')
474
+ if [ "${Centos9Check}" ];then
475
+ wget -O /usr/lib/systemd/system/btpanel.service ${download_Url}/init/systemd/btpanel.service
476
+ systemctl enable btpanel
477
+ fi
478
+ elif [ "${PM}" == "apt-get" ]; then
479
+ update-rc.d bt defaults
480
+ fi
481
+ }
482
+ Set_Centos7_Repo(){
483
+ # CN_YUM_URL=$(grep -E "aliyun|163|tencent|tsinghua" /etc/yum.repos.d/CentOS-Base.repo)
484
+ # if [ -z "${CN_YUM_URL}" ];then
485
+ # if [ -z "${download_Url}" ];then
486
+ # download_Url="http://download.bt.cn"
487
+ # fi
488
+ # curl -Ss --connect-timeout 3 -m 60 ${download_Url}/install/vault-repo.sh|bash
489
+ # return
490
+ # fi
491
+ MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Base.repo |grep "[^#]mirror.centos.org")
492
+ if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
493
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
494
+ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
495
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
496
+ fi
497
+
498
+ TSU_MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Base.repo |grep "tuna.tsinghua.edu.cn")
499
+ if [ "${TSU_MIRROR_CHECK}" ];then
500
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
501
+ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
502
+ sed -i 's|#baseurl=https://mirrors.tuna.tsinghua.edu.cn|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
503
+ sed -i 's|#baseurl=http://mirrors.tuna.tsinghua.edu.cn|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
504
+ sed -i 's|baseurl=https://mirrors.tuna.tsinghua.edu.cn|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
505
+ sed -i 's|baseurl=http://mirrors.tuna.tsinghua.edu.cn|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
506
+ fi
507
+
508
+ ALI_CLOUD_CHECK=$(grep Alibaba /etc/motd)
509
+ Tencent_Cloud=$(cat /etc/hostname |grep -E VM-[0-9]+-[0-9]+)
510
+ if [ "${ALI_CLOUD_CHECK}" ] || [ "${Tencent_Cloud}" ];then
511
+ return
512
+ fi
513
+
514
+ yum install unzip -y
515
+ if [ "$?" != "0" ] ;then
516
+ TAR_CHECK=$(which tar)
517
+ if [ "$?" == "0" ] ;then
518
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
519
+ if [ -z "${download_Url}" ];then
520
+ download_Url="http://download.bt.cn"
521
+ fi
522
+ curl -Ss --connect-timeout 5 -m 60 -O ${download_Url}/src/el7repo.tar.gz
523
+ rm -f /etc/yum.repos.d/*.repo
524
+ tar -xvzf el7repo.tar.gz -C /etc/yum.repos.d/
525
+ fi
526
+ fi
527
+
528
+ yum install unzip -y
529
+ if [ "$?" != "0" ] ;then
530
+ sed -i "s/vault.epel.cloud/mirrors.cloud.tencent.com/g" /etc/yum.repos.d/*.repo
531
+ fi
532
+ }
533
+ Set_Centos8_Repo(){
534
+ HUAWEI_CHECK=$(cat /etc/motd |grep "Huawei Cloud")
535
+ if [ "${HUAWEI_CHECK}" ] && [ "${is64bit}" == "64" ];then
536
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
537
+ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
538
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
539
+ rm -f /etc/yum.repos.d/epel.repo
540
+ rm -f /etc/yum.repos.d/epel-*
541
+ fi
542
+ ALIYUN_CHECK=$(cat /etc/motd|grep "Alibaba Cloud ")
543
+ if [ "${ALIYUN_CHECK}" ] && [ "${is64bit}" == "64" ] && [ ! -f "/etc/yum.repos.d/Centos-vault-8.5.2111.repo" ];then
544
+ rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
545
+ wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
546
+ wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo
547
+ sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo
548
+ sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo
549
+ fi
550
+ MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Linux-AppStream.repo |grep "[^#]mirror.centos.org")
551
+ if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
552
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
553
+ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
554
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
555
+ fi
556
+
557
+ yum install unzip tar -y
558
+ if [ "$?" != "0" ] ;then
559
+ if [ -z "${download_Url}" ];then
560
+ download_Url="http://download.bt.cn"
561
+ fi
562
+ if [ ! -f "/usr/bin/tar" ] ;then
563
+ curl -Ss --connect-timeout 5 -m 60 -O ${download_Url}/src/tar-1.30-5.el8.x86_64.rpm
564
+ yum install tar-1.30-5.el8.x86_64.rpm -y
565
+ fi
566
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
567
+ curl -Ss --connect-timeout 5 -m 60 -O ${download_Url}/src/el8repo.tar.gz
568
+ rm -f /etc/yum.repos.d/*.repo
569
+ tar -xvzf el8repo.tar.gz -C /etc/yum.repos.d/
570
+ fi
571
+
572
+ yum install unzip tar -y
573
+ if [ "$?" != "0" ] ;then
574
+ sed -i "s/vault.epel.cloud/mirrors.cloud.tencent.com/g" /etc/yum.repos.d/*.repo
575
+ fi
576
+ }
577
+ get_node_url(){
578
+ if [ "${PM}" = "yum" ]; then
579
+ yum install wget -y
580
+ fi
581
+ if [ ! -f /bin/curl ];then
582
+ if [ "${PM}" = "yum" ]; then
583
+ yum install curl -y
584
+ elif [ "${PM}" = "apt-get" ]; then
585
+ apt-get install curl -y
586
+ fi
587
+ fi
588
+
589
+ if [ -f "/www/node.pl" ];then
590
+ download_Url=$(cat /www/node.pl)
591
+ echo "Download node: $download_Url";
592
+ echo '---------------------------------------------';
593
+ return
594
+ fi
595
+
596
+ echo '---------------------------------------------';
597
+ echo "Selected download node...";
598
+ nodes=(https://dg2.bt.cn https://download.bt.cn https://ctcc1-node.bt.cn https://cmcc1-node.bt.cn https://ctcc2-node.bt.cn https://hk1-node.bt.cn https://na1-node.bt.cn https://jp1-node.bt.cn https://cf1-node.aapanel.com https://download.bt.cn);
599
+
600
+ CURL_CHECK=$(which curl)
601
+ if [ "$?" == "0" ];then
602
+ CN_CHECK=$(curl -sS --connect-timeout 10 -m 10 https://api.bt.cn/api/isCN)
603
+ if [ "${CN_CHECK}" == "True" ];then
604
+ nodes=(https://dg2.bt.cn https://download.bt.cn https://ctcc1-node.bt.cn https://cmcc1-node.bt.cn https://ctcc2-node.bt.cn https://hk1-node.bt.cn);
605
+ fi
606
+ fi
607
+
608
+ if [ "$1" ];then
609
+ nodes=($(echo ${nodes[*]}|sed "s#${1}##"))
610
+ fi
611
+
612
+ tmp_file1=/dev/shm/net_test1.pl
613
+ tmp_file2=/dev/shm/net_test2.pl
614
+ [ -f "${tmp_file1}" ] && rm -f ${tmp_file1}
615
+ [ -f "${tmp_file2}" ] && rm -f ${tmp_file2}
616
+ touch $tmp_file1
617
+ touch $tmp_file2
618
+ for node in ${nodes[@]};
619
+ do
620
+ NODE_CHECK=$(curl --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${node}/net_test|xargs)
621
+ RES=$(echo ${NODE_CHECK}|awk '{print $1}')
622
+ NODE_STATUS=$(echo ${NODE_CHECK}|awk '{print $2}')
623
+ TIME_TOTAL=$(echo ${NODE_CHECK}|awk '{print $3 * 1000 - 500 }'|cut -d '.' -f 1)
624
+ if [ "${NODE_STATUS}" == "200" ];then
625
+ if [ $TIME_TOTAL -lt 300 ];then
626
+ if [ $RES -ge 1500 ];then
627
+ echo "$RES $node" >> $tmp_file1
628
+ fi
629
+ else
630
+ if [ $RES -ge 1500 ];then
631
+ echo "$TIME_TOTAL $node" >> $tmp_file2
632
+ fi
633
+ fi
634
+
635
+ i=$(($i+1))
636
+ if [ $TIME_TOTAL -lt 300 ];then
637
+ if [ $RES -ge 2390 ];then
638
+ break;
639
+ fi
640
+ fi
641
+ fi
642
+ done
643
+
644
+ NODE_URL=$(cat $tmp_file1|sort -r -g -t " " -k 1|head -n 1|awk '{print $2}')
645
+ if [ -z "$NODE_URL" ];then
646
+ NODE_URL=$(cat $tmp_file2|sort -g -t " " -k 1|head -n 1|awk '{print $2}')
647
+ if [ -z "$NODE_URL" ];then
648
+ NODE_URL='https://download.bt.cn';
649
+ fi
650
+ fi
651
+ rm -f $tmp_file1
652
+ rm -f $tmp_file2
653
+ download_Url=$NODE_URL
654
+ echo "Download node: $download_Url";
655
+ echo '---------------------------------------------';
656
+ }
657
+ Remove_Package(){
658
+ local PackageNmae=$1
659
+ if [ "${PM}" == "yum" ];then
660
+ isPackage=$(rpm -q ${PackageNmae}|grep "not installed")
661
+ if [ -z "${isPackage}" ];then
662
+ yum remove ${PackageNmae} -y
663
+ fi
664
+ elif [ "${PM}" == "apt-get" ];then
665
+ isPackage=$(dpkg -l|grep ${PackageNmae})
666
+ if [ "${PackageNmae}" ];then
667
+ apt-get remove ${PackageNmae} -y
668
+ fi
669
+ fi
670
+ }
671
+ Install_RPM_Pack(){
672
+ yumPath=/etc/yum.conf
673
+
674
+ CentosStream8Check=$(cat /etc/redhat-release |grep Stream|grep 8)
675
+ if [ "${CentosStream8Check}" ];then
676
+ MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Stream-AppStream.repo|grep "[^#]mirror.centos.org")
677
+ if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
678
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
679
+ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
680
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
681
+ fi
682
+ fi
683
+
684
+ Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
685
+ if [ "${Centos8Check}" ];then
686
+ Set_Centos8_Repo
687
+ fi
688
+ Centos7Check=$(cat /etc/redhat-release | grep ' 7.' | grep -iE 'centos|Red Hat')
689
+ if [ "${Centos7Check}" ];then
690
+ Set_Centos7_Repo
691
+ fi
692
+ isExc=$(cat $yumPath|grep httpd)
693
+ if [ "$isExc" = "" ];then
694
+ echo "exclude=httpd nginx php mysql mairadb python-psutil python2-psutil" >> $yumPath
695
+ fi
696
+
697
+ if [ -f "/etc/redhat-release" ] && [ $(cat /etc/os-release|grep PLATFORM_ID|grep -oE "el8") ];then
698
+ yum config-manager --set-enabled powertools
699
+ yum config-manager --set-enabled PowerTools
700
+ fi
701
+
702
+ if [ -f "/etc/redhat-release" ] && [ $(cat /etc/os-release|grep PLATFORM_ID|grep -oE "el9") ];then
703
+ dnf config-manager --set-enabled crb -y
704
+ fi
705
+
706
+ #SYS_TYPE=$(uname -a|grep x86_64)
707
+ #yumBaseUrl=$(cat /etc/yum.repos.d/CentOS-Base.repo|grep baseurl=http|cut -d '=' -f 2|cut -d '$' -f 1|head -n 1)
708
+ #[ "${yumBaseUrl}" ] && checkYumRepo=$(curl --connect-timeout 5 --head -s -o /dev/null -w %{http_code} ${yumBaseUrl})
709
+ #if [ "${checkYumRepo}" != "200" ] && [ "${SYS_TYPE}" ];then
710
+ # curl -Ss --connect-timeout 3 -m 60 http://download.bt.cn/install/yumRepo_select.sh|bash
711
+ #fi
712
+
713
+ #尝试同步时间(从bt.cn)
714
+ echo 'Synchronizing system time...'
715
+ getBtTime=$(curl -sS --connect-timeout 3 -m 60 http://www.bt.cn/api/index/get_time)
716
+ if [ "${getBtTime}" ];then
717
+ date -s "$(date -d @$getBtTime +"%Y-%m-%d %H:%M:%S")"
718
+ fi
719
+
720
+ if [ -z "${Centos8Check}" ]; then
721
+ yum install ntp -y
722
+ rm -rf /etc/localtime
723
+ ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
724
+
725
+ #尝试同步国际时间(从ntp服务器)
726
+ ntpdate 0.asia.pool.ntp.org
727
+ setenforce 0
728
+ fi
729
+
730
+ startTime=`date +%s`
731
+
732
+ sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
733
+ #yum remove -y python-requests python3-requests python-greenlet python3-greenlet
734
+ yumPacks="libcurl-devel wget tar gcc make zip unzip openssl openssl-devel gcc libxml2 libxml2-devel libxslt* zlib zlib-devel libjpeg-devel libpng-devel libwebp libwebp-devel freetype freetype-devel lsof pcre pcre-devel vixie-cron crontabs icu libicu-devel c-ares libffi-devel bzip2-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel qrencode at mariadb rsyslog net-tools"
735
+ yum install -y ${yumPacks}
736
+
737
+ for yumPack in ${yumPacks}
738
+ do
739
+ rpmPack=$(rpm -q ${yumPack})
740
+ packCheck=$(echo ${rpmPack}|grep not)
741
+ if [ "${packCheck}" ]; then
742
+ yum install ${yumPack} -y
743
+ fi
744
+ done
745
+ if [ -f "/usr/bin/dnf" ]; then
746
+ dnf install -y redhat-rpm-config
747
+ fi
748
+
749
+ ALI_OS=$(cat /etc/redhat-release |grep "Alibaba Cloud Linux release 3")
750
+ if [ -z "${ALI_OS}" ];then
751
+ yum install epel-release -y
752
+ fi
753
+ }
754
+ Install_Deb_Pack(){
755
+ ln -sf bash /bin/sh
756
+ UBUNTU_22=$(cat /etc/issue|grep "Ubuntu 22")
757
+ UBUNTU_24=$(cat /etc/issue|grep "Ubuntu 24")
758
+ if [ "${UBUNTU_22}" ] || [ "${UBUNTU_24}" ];then
759
+ apt-get remove needrestart -y
760
+ fi
761
+ ALIYUN_CHECK=$(cat /etc/motd|grep "Alibaba Cloud ")
762
+ if [ "${ALIYUN_CHECK}" ] && [ "${UBUNTU_22}" ];then
763
+ apt-get remove libicu70 -y
764
+ fi
765
+ apt-get update -y
766
+
767
+ FNOS_CHECK=$(cat /etc/issue|grep fnOS)
768
+ if [ "${FNOS_CHECK}" ];then
769
+ apt-get install libc6 --allow-change-held-packages -y
770
+ apt-get install libc6-dev --allow-change-held-packages -y
771
+ fi
772
+
773
+ apt-get install bash -y
774
+ if [ -f "/usr/bin/bash" ];then
775
+ ln -sf /usr/bin/bash /bin/sh
776
+ fi
777
+ apt-get install ruby -y
778
+ apt-get install lsb-release -y
779
+ #apt-get install ntp ntpdate -y
780
+ #/etc/init.d/ntp stop
781
+ #update-rc.d ntp remove
782
+ #cat >>~/.profile<<EOF
783
+ #TZ='Asia/Shanghai'; export TZ
784
+ #EOF
785
+ #rm -rf /etc/localtime
786
+ #cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
787
+ #echo 'Synchronizing system time...'
788
+ #ntpdate 0.asia.pool.ntp.org
789
+ #apt-get upgrade -y
790
+ LIBCURL_VER=$(dpkg -l|grep libcurl4|awk '{print $3}')
791
+ if [ "${LIBCURL_VER}" == "7.68.0-1ubuntu2.8" ];then
792
+ apt-get remove libcurl4 -y
793
+ apt-get install curl -y
794
+ fi
795
+
796
+ debPacks="wget curl libcurl4-openssl-dev gcc make zip unzip tar openssl libssl-dev gcc libxml2 libxml2-dev zlib1g zlib1g-dev libjpeg-dev libpng-dev lsof libpcre3 libpcre3-dev cron net-tools swig build-essential libffi-dev libbz2-dev libncurses-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libdb++-dev libpcap-dev xz-utils git qrencode sqlite3 at mariadb-client rsyslog net-tools";
797
+ apt-get install -y $debPacks --force-yes
798
+
799
+ for debPack in ${debPacks}
800
+ do
801
+ packCheck=$(dpkg -l|grep ${debPack})
802
+ if [ "$?" -ne "0" ] ;then
803
+ apt-get install -y $debPack
804
+ fi
805
+ done
806
+
807
+ if [ ! -d '/etc/letsencrypt' ];then
808
+ mkdir -p /etc/letsencryp
809
+ mkdir -p /var/spool/cron
810
+ if [ ! -f '/var/spool/cron/crontabs/root' ];then
811
+ echo '' > /var/spool/cron/crontabs/root
812
+ chmod 600 /var/spool/cron/crontabs/root
813
+ fi
814
+ fi
815
+ }
816
+ Get_Versions(){
817
+ redhat_version_file="/etc/redhat-release"
818
+ deb_version_file="/etc/issue"
819
+
820
+ if [[ $(grep Anolis /etc/os-release) ]] && [[ $(grep VERSION /etc/os-release|grep 8.8) ]];then
821
+ if [ -f "/usr/bin/yum" ];then
822
+ os_type="anolis"
823
+ os_version="8"
824
+ return
825
+ fi
826
+ fi
827
+
828
+
829
+ if [ -f "/etc/os-release" ];then
830
+ . /etc/os-release
831
+ OS_V=${VERSION_ID%%.*}
832
+ if [ "${ID}" == "opencloudos" ] && [[ "${OS_V}" =~ ^(9)$ ]];then
833
+ os_type="opencloudos"
834
+ os_version="9"
835
+ pyenv_tt="true"
836
+ elif { [ "${ID}" == "almalinux" ] || [ "${ID}" == "centos" ] || [ "${ID}" == "rocky" ]; } && [[ "${OS_V}" =~ ^(9)$ ]]; then
837
+ os_type="el"
838
+ os_version="9"
839
+ pyenv_tt="true"
840
+ fi
841
+ if [ "${pyenv_tt}" ];then
842
+ return
843
+ fi
844
+ fi
845
+
846
+ if [ -f $redhat_version_file ];then
847
+ os_type='el'
848
+ is_aliyunos=$(cat $redhat_version_file|grep Aliyun)
849
+ if [ "$is_aliyunos" != "" ];then
850
+ return
851
+ fi
852
+
853
+ if [[ $(grep "Alibaba Cloud" /etc/redhat-release) ]] && [[ $(grep al8 /etc/os-release) ]];then
854
+ os_type="ali-linux-"
855
+ os_version="al8"
856
+ return
857
+ fi
858
+
859
+ if [[ $(grep "TencentOS Server" /etc/redhat-release|grep 3.1) ]];then
860
+ os_type="TencentOS-"
861
+ os_version="3.1"
862
+ return
863
+ fi
864
+
865
+ os_version=$(cat $redhat_version_file|grep CentOS|grep -Eo '([0-9]+\.)+[0-9]+'|grep -Eo '^[0-9]')
866
+ if [ "${os_version}" = "5" ];then
867
+ os_version=""
868
+ fi
869
+ if [ -z "${os_version}" ];then
870
+ os_version=$(cat /etc/redhat-release |grep Stream|grep -oE 8)
871
+ fi
872
+ else
873
+ os_type='ubuntu'
874
+ os_version=$(cat $deb_version_file|grep Ubuntu|grep -Eo '([0-9]+\.)+[0-9]+'|grep -Eo '^[0-9]+')
875
+ if [ "${os_version}" = "" ];then
876
+ os_type='debian'
877
+ os_version=$(cat $deb_version_file|grep Debian|grep -Eo '([0-9]+\.)+[0-9]+'|grep -Eo '[0-9]+')
878
+ if [ "${os_version}" = "" ];then
879
+ os_version=$(cat $deb_version_file|grep Debian|grep -Eo '[0-9]+')
880
+ fi
881
+ if [ "${os_version}" = "8" ];then
882
+ os_version=""
883
+ fi
884
+ if [ "${is64bit}" = '32' ];then
885
+ os_version=""
886
+ fi
887
+ else
888
+ if [ "$os_version" = "14" ];then
889
+ os_version=""
890
+ fi
891
+ if [ "$os_version" = "12" ];then
892
+ os_version=""
893
+ fi
894
+ if [ "$os_version" = "19" ];then
895
+ os_version=""
896
+ fi
897
+ if [ "$os_version" = "21" ];then
898
+ os_version=""
899
+ fi
900
+ if [ "$os_version" = "20" ];then
901
+ os_version2004=$(cat /etc/issue|grep 20.04)
902
+ if [ -z "${os_version2004}" ];then
903
+ os_version=""
904
+ fi
905
+ fi
906
+ fi
907
+ fi
908
+ }
909
+ Install_Python_Lib(){
910
+ curl -Ss --connect-timeout 3 -m 60 $download_Url/install/pip_select.sh|bash
911
+ pyenv_path="/www/server/panel"
912
+ if [ -f $pyenv_path/pyenv/bin/python ];then
913
+ is_ssl=$($python_bin -c "import ssl" 2>&1|grep cannot)
914
+ $pyenv_path/pyenv/bin/python3.7 -V
915
+ if [ $? -eq 0 ] && [ -z "${is_ssl}" ];then
916
+ chmod -R 700 $pyenv_path/pyenv/bin
917
+ is_package=$($python_bin -m psutil 2>&1|grep package)
918
+ if [ "$is_package" = "" ];then
919
+ wget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip.txt -T 15
920
+ $pyenv_path/pyenv/bin/pip install -U pip
921
+ $pyenv_path/pyenv/bin/pip install -U setuptools==65.5.0
922
+ $pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.txt
923
+ fi
924
+ source $pyenv_path/pyenv/bin/activate
925
+ chmod -R 700 $pyenv_path/pyenv/bin
926
+ return
927
+ else
928
+ rm -rf $pyenv_path/pyenv
929
+ fi
930
+ fi
931
+
932
+ is_loongarch64=$(uname -a|grep loongarch64)
933
+ if [ "$is_loongarch64" != "" ] && [ -f "/usr/bin/yum" ];then
934
+ yumPacks="python3-devel python3-pip python3-psutil python3-gevent python3-pyOpenSSL python3-paramiko python3-flask python3-rsa python3-requests python3-six python3-websocket-client"
935
+ yum install -y ${yumPacks}
936
+ for yumPack in ${yumPacks}
937
+ do
938
+ rpmPack=$(rpm -q ${yumPack})
939
+ packCheck=$(echo ${rpmPack}|grep not)
940
+ if [ "${packCheck}" ]; then
941
+ yum install ${yumPack} -y
942
+ fi
943
+ done
944
+
945
+ pip3 install -U pip
946
+ pip3 install Pillow psutil pyinotify pycryptodome upyun oss2 pymysql qrcode qiniu redis pymongo Cython configparser cos-python-sdk-v5 supervisor gevent-websocket pyopenssl
947
+ pip3 install flask==1.1.4
948
+ pip3 install Pillow -U
949
+
950
+ pyenv_bin=/www/server/panel/pyenv/bin
951
+ mkdir -p $pyenv_bin
952
+ ln -sf /usr/local/bin/pip3 $pyenv_bin/pip
953
+ ln -sf /usr/local/bin/pip3 $pyenv_bin/pip3
954
+ ln -sf /usr/local/bin/pip3 $pyenv_bin/pip3.7
955
+
956
+ if [ -f "/usr/bin/python3.7" ];then
957
+ ln -sf /usr/bin/python3.7 $pyenv_bin/python
958
+ ln -sf /usr/bin/python3.7 $pyenv_bin/python3
959
+ ln -sf /usr/bin/python3.7 $pyenv_bin/python3.7
960
+ elif [ -f "/usr/bin/python3.6" ]; then
961
+ ln -sf /usr/bin/python3.6 $pyenv_bin/python
962
+ ln -sf /usr/bin/python3.6 $pyenv_bin/python3
963
+ ln -sf /usr/bin/python3.6 $pyenv_bin/python3.7
964
+ fi
965
+
966
+ echo > $pyenv_bin/activate
967
+
968
+ return
969
+ fi
970
+
971
+ py_version="3.7.16"
972
+ mkdir -p $pyenv_path
973
+ echo "True" > /www/disk.pl
974
+ if [ ! -w /www/disk.pl ];then
975
+ Red_Error "ERROR: Install python env fielded." "ERROR: /www目录无法写入,请检查目录/用户/磁盘权限!"
976
+ fi
977
+ os_type='el'
978
+ os_version='7'
979
+ is_export_openssl=0
980
+ Get_Versions
981
+
982
+ echo "OS: $os_type - $os_version"
983
+ is_aarch64=$(uname -a|grep aarch64)
984
+ if [ "$is_aarch64" != "" ];then
985
+ is64bit="aarch64"
986
+ fi
987
+
988
+ if [ -f "/www/server/panel/pymake.pl" ];then
989
+ os_version=""
990
+ rm -f /www/server/panel/pymake.pl
991
+ fi
992
+ echo "==============================================="
993
+ echo "正在下载面板运行环境,请稍等..............."
994
+ echo "==============================================="
995
+ if [ "${os_version}" != "" ];then
996
+ pyenv_file="/www/pyenv.tar.gz"
997
+ wget -O $pyenv_file $download_Url/install/pyenv/pyenv-${os_type}${os_version}-x${is64bit}.tar.gz -T 20
998
+ if [ "$?" != "0" ];then
999
+ get_node_url $download_Url
1000
+ wget -O $pyenv_file $download_Url/install/pyenv/pyenv-${os_type}${os_version}-x${is64bit}.tar.gz -T 20
1001
+ fi
1002
+ tmp_size=$(du -b $pyenv_file|awk '{print $1}')
1003
+ if [ $tmp_size -lt 703460 ];then
1004
+ rm -f $pyenv_file
1005
+ echo "ERROR: Download python env fielded."
1006
+ else
1007
+ echo "Install python env..."
1008
+ tar zxvf $pyenv_file -C $pyenv_path/ > /dev/null
1009
+ chmod -R 700 $pyenv_path/pyenv/bin
1010
+ if [ ! -f $pyenv_path/pyenv/bin/python ];then
1011
+ rm -f $pyenv_file
1012
+ Red_Error "ERROR: Install python env fielded." "ERROR: 下载宝塔运行环境失败,请尝试重新安装!"
1013
+ fi
1014
+ $pyenv_path/pyenv/bin/python3.7 -V
1015
+ if [ $? -eq 0 ];then
1016
+ rm -f $pyenv_file
1017
+ ln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip
1018
+ ln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython
1019
+ source $pyenv_path/pyenv/bin/activate
1020
+ return
1021
+ else
1022
+ rm -f $pyenv_file
1023
+ rm -rf $pyenv_path/pyenv
1024
+ fi
1025
+ fi
1026
+ fi
1027
+
1028
+ cd /www
1029
+ python_src='/www/python_src.tar.xz'
1030
+ python_src_path="/www/Python-${py_version}"
1031
+ wget -O $python_src $download_Url/src/Python-${py_version}.tar.xz -T 15
1032
+ tmp_size=$(du -b $python_src|awk '{print $1}')
1033
+ if [ $tmp_size -lt 10703460 ];then
1034
+ rm -f $python_src
1035
+ Red_Error "ERROR: Download python source code fielded." "ERROR: 下载宝塔运行环境失败,请尝试重新安装!"
1036
+ fi
1037
+ tar xvf $python_src
1038
+ rm -f $python_src
1039
+ cd $python_src_path
1040
+ ./configure --prefix=$pyenv_path/pyenv
1041
+ make -j$cpu_cpunt
1042
+ make install
1043
+ if [ ! -f $pyenv_path/pyenv/bin/python3.7 ];then
1044
+ rm -rf $python_src_path
1045
+ Red_Error "ERROR: Make python env fielded." "ERROR: 编译宝塔运行环境失败!"
1046
+ fi
1047
+ cd ~
1048
+ rm -rf $python_src_path
1049
+ wget -O $pyenv_path/pyenv/bin/activate $download_Url/install/pyenv/activate.panel -T 5
1050
+ wget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip-3.7.16.txt -T 5
1051
+ ln -sf $pyenv_path/pyenv/bin/pip3.7 $pyenv_path/pyenv/bin/pip
1052
+ ln -sf $pyenv_path/pyenv/bin/python3.7 $pyenv_path/pyenv/bin/python
1053
+ ln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip
1054
+ ln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython
1055
+ chmod -R 700 $pyenv_path/pyenv/bin
1056
+ $pyenv_path/pyenv/bin/pip install -U pip
1057
+ $pyenv_path/pyenv/bin/pip install -U setuptools==65.5.0
1058
+ $pyenv_path/pyenv/bin/pip install -U wheel==0.34.2
1059
+ $pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.txt
1060
+
1061
+ wget -O pip-packs.txt $download_Url/install/pyenv/pip-packs.txt
1062
+ echo "正在后台安装pip依赖请稍等.........."
1063
+ PIP_PACKS=$(cat pip-packs.txt)
1064
+ for P_PACK in ${PIP_PACKS};
1065
+ do
1066
+ btpip show ${P_PACK} > /dev/null 2>&1
1067
+ if [ "$?" == "1" ];then
1068
+ btpip install ${P_PACK}
1069
+ fi
1070
+ done
1071
+
1072
+ rm -f pip-packs.txt
1073
+
1074
+ source $pyenv_path/pyenv/bin/activate
1075
+
1076
+ btpip install psutil
1077
+ btpip install gevent
1078
+
1079
+ is_gevent=$($python_bin -m gevent 2>&1|grep -oE package)
1080
+ is_psutil=$($python_bin -m psutil 2>&1|grep -oE package)
1081
+ if [ "${is_gevent}" != "${is_psutil}" ];then
1082
+ Red_Error "ERROR: psutil/gevent install failed!"
1083
+ fi
1084
+ }
1085
+ Install_Bt(){
1086
+ if [ -f ${setup_path}/server/panel/data/port.pl ];then
1087
+ panelPort=$(cat ${setup_path}/server/panel/data/port.pl)
1088
+ fi
1089
+ if [ "${PANEL_PORT}" ];then
1090
+ panelPort=$PANEL_PORT
1091
+ fi
1092
+ mkdir -p ${setup_path}/server/panel/logs
1093
+ mkdir -p ${setup_path}/server/panel/vhost/apache
1094
+ mkdir -p ${setup_path}/server/panel/vhost/nginx
1095
+ mkdir -p ${setup_path}/server/panel/vhost/rewrite
1096
+ mkdir -p ${setup_path}/server/panel/install
1097
+ mkdir -p /www/server
1098
+ mkdir -p /www/wwwroot
1099
+ mkdir -p /www/wwwlogs
1100
+ mkdir -p /www/backup/database
1101
+ mkdir -p /www/backup/site
1102
+
1103
+ if [ ! -d "/etc/init.d" ];then
1104
+ mkdir -p /etc/init.d
1105
+ fi
1106
+
1107
+ if [ -f "/etc/init.d/bt" ]; then
1108
+ /etc/init.d/bt stop
1109
+ sleep 1
1110
+ fi
1111
+
1112
+ wget -O /etc/init.d/bt ${download_Url}/install/src/bt6.init -T 15
1113
+ wget -O /www/server/panel/install/public.sh ${download_Url}/install/public.sh -T 15
1114
+ echo "=============================================="
1115
+ echo "正在下载面板文件,请稍等..................."
1116
+ echo "=============================================="
1117
+ wget -O panel.zip ${download_Url}/install/src/LinuxPanelStable.zip -T 15
1118
+ #wget -O panel.zip ${download_Url}/install/src/panel-lts.zip -T 15
1119
+
1120
+ if [ -f "${setup_path}/server/panel/data/default.db" ];then
1121
+ if [ -d "/${setup_path}/server/panel/old_data" ];then
1122
+ rm -rf ${setup_path}/server/panel/old_data
1123
+ fi
1124
+ mkdir -p ${setup_path}/server/panel/old_data
1125
+ d_format=$(date +"%Y%m%d_%H%M%S")
1126
+ \cp -arf ${setup_path}/server/panel/data/default.db ${setup_path}/server/panel/data/default_backup_${d_format}.db
1127
+ mv -f ${setup_path}/server/panel/data/default.db ${setup_path}/server/panel/old_data/default.db
1128
+ mv -f ${setup_path}/server/panel/data/system.db ${setup_path}/server/panel/old_data/system.db
1129
+ mv -f ${setup_path}/server/panel/data/port.pl ${setup_path}/server/panel/old_data/port.pl
1130
+ mv -f ${setup_path}/server/panel/data/admin_path.pl ${setup_path}/server/panel/old_data/admin_path.pl
1131
+
1132
+ if [ -d "${setup_path}/server/panel/data/db" ];then
1133
+ \cp -r ${setup_path}/server/panel/data/db ${setup_path}/server/panel/old_data/
1134
+ fi
1135
+
1136
+ fi
1137
+
1138
+ if [ ! -f "/usr/bin/unzip" ]; then
1139
+ if [ "${PM}" = "yum" ]; then
1140
+ yum install unzip -y
1141
+ elif [ "${PM}" = "apt-get" ]; then
1142
+ apt-get update
1143
+ apt-get install unzip -y 2>&1|tee /tmp/apt_install_log.log
1144
+ UNZIP_CHECK=$(which unzip)
1145
+ if [ "$?" != "0" ];then
1146
+ RECONFIGURE_CHECK=$(grep "dpkg --configure -a" /tmp/apt_install_log.log)
1147
+ if [ "${RECONFIGURE_CHECK}" ];then
1148
+ dpkg --configure -a
1149
+ fi
1150
+ APT_LOCK_CHECH=$(grep "/var/lib/dpkg/lock" /tmp/apt_install_log.log)
1151
+ if [ "${APT_LOCK_CHECH}" ];then
1152
+ pkill dpkg
1153
+ pkill apt-get
1154
+ pkill apt
1155
+ [ -e /var/lib/dpkg/lock-frontend ] && rm -f /var/lib/dpkg/lock-frontend
1156
+ [ -e /var/lib/dpkg/lock ] && rm -f /var/lib/dpkg/lock
1157
+ [ -e /var/lib/apt/lists/lock ] && rm -f /var/lib/apt/lists/lock
1158
+ [ -e /var/cache/apt/archives/lock ] && rm -f /var/cache/apt/archives/lock
1159
+ dpkg --configure -a
1160
+ fi
1161
+ sleep 5
1162
+ apt-get install unzip -y
1163
+ fi
1164
+ fi
1165
+ fi
1166
+
1167
+ unzip -o panel.zip -d ${setup_path}/server/ > /dev/null
1168
+
1169
+ if [ -d "${setup_path}/server/panel/old_data" ];then
1170
+ mv -f ${setup_path}/server/panel/old_data/default.db ${setup_path}/server/panel/data/default.db
1171
+ mv -f ${setup_path}/server/panel/old_data/system.db ${setup_path}/server/panel/data/system.db
1172
+ mv -f ${setup_path}/server/panel/old_data/port.pl ${setup_path}/server/panel/data/port.pl
1173
+ mv -f ${setup_path}/server/panel/old_data/admin_path.pl ${setup_path}/server/panel/data/admin_path.pl
1174
+
1175
+ if [ -d "${setup_path}/server/panel/old_data/db" ];then
1176
+ \cp -r ${setup_path}/server/panel/old_data/db ${setup_path}/server/panel/data/
1177
+ fi
1178
+
1179
+ if [ -d "/${setup_path}/server/panel/old_data" ];then
1180
+ rm -rf ${setup_path}/server/panel/old_data
1181
+ fi
1182
+ fi
1183
+
1184
+ if [ ! -f ${setup_path}/server/panel/tools.py ] || [ ! -f ${setup_path}/server/panel/BT-Panel ];then
1185
+ ls -lh panel.zip
1186
+ Red_Error "ERROR: Failed to download, please try install again!" "ERROR: 下载宝塔失败,请尝试重新安装!"
1187
+ fi
1188
+
1189
+ SYS_LOG_CHECK=$(grep ^weekly /etc/logrotate.conf)
1190
+ if [ "${SYS_LOG_CHECK}" ];then
1191
+ sed -i 's/rotate [0-9]*/rotate 8/g' /etc/logrotate.conf
1192
+ fi
1193
+
1194
+ rm -f panel.zip
1195
+ rm -f ${setup_path}/server/panel/class/*.pyc
1196
+ rm -f ${setup_path}/server/panel/*.pyc
1197
+
1198
+ chmod +x /etc/init.d/bt
1199
+ chmod -R 600 ${setup_path}/server/panel
1200
+ chmod -R +x ${setup_path}/server/panel/script
1201
+ ln -sf /etc/init.d/bt /usr/bin/bt
1202
+ echo "${panelPort}" > ${setup_path}/server/panel/data/port.pl
1203
+ wget -O /etc/init.d/bt ${download_Url}/install/src/bt7.init -T 15
1204
+ wget -O /www/server/panel/init.sh ${download_Url}/install/src/bt7.init -T 15
1205
+ wget -O /www/server/panel/data/softList.conf ${download_Url}/install/conf/softListtls10.conf
1206
+
1207
+ rm -rf /www/server/panel/plugin/webssh/
1208
+
1209
+ if [ ! -f "${setup_path}/server/panel/data/installCount.pl" ];then
1210
+ echo "1 $(date)" > ${setup_path}/server/panel/data/installCount.pl
1211
+ elif [ -f "${setup_path}/server/panel/data/installCount.pl" ];then
1212
+ INSTALL_COUNT=$(cat ${setup_path}/server/panel/data/installCount.pl|awk '{last=$1} END {print last}')
1213
+ echo "$((INSTALL_COUNT+1)) $(date)" >> ${setup_path}/server/panel/data/installCount.pl
1214
+ fi
1215
+
1216
+ }
1217
+ Set_Bt_Panel(){
1218
+ Run_User="www"
1219
+ wwwUser=$(cat /etc/passwd|cut -d ":" -f 1|grep ^www$)
1220
+ if [ "${wwwUser}" != "www" ];then
1221
+ groupadd ${Run_User}
1222
+ useradd -s /sbin/nologin -g ${Run_User} ${Run_User}
1223
+ fi
1224
+
1225
+ # Default credentials (non-interactive). Can be overridden via --user/--password.
1226
+ if [ "$PANEL_PASSWORD" ];then
1227
+ password=$PANEL_PASSWORD
1228
+ else
1229
+ password="TFBpLwpN8D"
1230
+ fi
1231
+ sleep 1
1232
+ admin_auth="/www/server/panel/data/admin_path.pl"
1233
+ if [ ! -f ${admin_auth} ];then
1234
+ auth_path="admin"
1235
+ echo "/${auth_path}" > ${admin_auth}
1236
+ fi
1237
+ if [ "${SAFE_PATH}" ];then
1238
+ auth_path=$SAFE_PATH
1239
+ echo "/${auth_path}" > ${admin_auth}
1240
+ fi
1241
+ chmod -R 700 $pyenv_path/pyenv/bin
1242
+ if [ ! -f "/www/server/panel/pyenv/n.pl" ];then
1243
+ btpip install docxtpl==0.16.7
1244
+ /www/server/panel/pyenv/bin/pip3 install pymongo
1245
+ /www/server/panel/pyenv/bin/pip3 install psycopg2-binary
1246
+ /www/server/panel/pyenv/bin/pip3 install flask -U
1247
+ /www/server/panel/pyenv/bin/pip3 install flask-sock
1248
+ /www/server/panel/pyenv/bin/pip3 install -I gevent
1249
+ btpip install simple-websocket==0.10.0
1250
+ btpip install natsort
1251
+ btpip uninstall enum34 -y
1252
+ btpip install geoip2==4.7.0
1253
+ btpip install brotli
1254
+ btpip install PyMySQL
1255
+ fi
1256
+ auth_path=$(cat ${admin_auth})
1257
+ cd ${setup_path}/server/panel/
1258
+ /etc/init.d/bt start
1259
+ $python_bin -m py_compile tools.py
1260
+ $python_bin tools.py username
1261
+ username=$($python_bin tools.py panel ${password})
1262
+ if [ "$PANEL_USER" ];then
1263
+ username=$PANEL_USER
1264
+ else
1265
+ username="7k2cl1yr"
1266
+ fi
1267
+ cd ~
1268
+ echo "${password}" > ${setup_path}/server/panel/default.pl
1269
+ chmod 600 ${setup_path}/server/panel/default.pl
1270
+ sleep 3
1271
+ if [ "$SET_SSL" == true ]; then
1272
+ if [ ! -f "/www/server/panel/pyenv/n.pl" ];then
1273
+ btpip install -I pyOpenSSl 2>/dev/null
1274
+ fi
1275
+ echo "========================================"
1276
+ echo "正在开启面板SSL,请稍等............ "
1277
+ echo "========================================"
1278
+ SSL_STATUS=$(btpython /www/server/panel/tools.py ssl)
1279
+ if [ "${SSL_STATUS}" == "0" ] ;then
1280
+ echo -n " -4 " > /www/server/panel/data/v4.pl
1281
+ btpython /www/server/panel/tools.py ssl
1282
+ fi
1283
+ echo "证书开启成功!"
1284
+ echo "========================================"
1285
+ fi
1286
+ /etc/init.d/bt stop
1287
+ sleep 5
1288
+ /etc/init.d/bt start
1289
+ sleep 5
1290
+ isStart=$(ps aux |grep 'BT-Panel'|grep -v grep|awk '{print $2}')
1291
+ LOCAL_CURL=$(curl 127.0.0.1:${panelPort}/login 2>&1 |grep -i html)
1292
+ if [ -z "${isStart}" ];then
1293
+ /etc/init.d/bt 22
1294
+ cd /www/server/panel/pyenv/bin
1295
+ touch t.pl
1296
+ ls -al python3.7 python
1297
+ lsattr python3.7 python
1298
+ btpython /www/server/panel/BT-Panel
1299
+ Red_Error "ERROR: The BT-Panel service startup failed." "ERROR: 宝塔启动失败"
1300
+ fi
1301
+ # wget -O oneav_bt.sh https://download.bt.cn/install/plugin/oneav/install.sh > /dev/null 2>&1
1302
+ # bash oneav_bt.sh install > /www/server/panel/install//btinstall.log 2>&1
1303
+ # rm -f oneav_bt.sh
1304
+
1305
+ cd ${setup_path}/server/panel/
1306
+ btpython -c 'import tools;tools.set_panel_username("'$username'")'
1307
+ cd ~
1308
+ if [ -f "/usr/bin/sqlite3" ] ;then
1309
+ sqlite3 /www/server/panel/data/db/panel.db "UPDATE config SET status = '1' WHERE id = '1';" > /dev/null 2>&1
1310
+ fi
1311
+ }
1312
+ Set_Firewall(){
1313
+ sshPort=$(cat /etc/ssh/sshd_config | grep 'Port '|awk '{print $2}')
1314
+ if [ "${PM}" = "apt-get" ]; then
1315
+ apt-get install -y ufw
1316
+ if [ -f "/usr/sbin/ufw" ];then
1317
+ ufw allow 20/tcp
1318
+ ufw allow 21/tcp
1319
+ ufw allow 22/tcp
1320
+ ufw allow 80/tcp
1321
+ ufw allow 443/tcp
1322
+ ufw allow 888/tcp
1323
+ ufw allow ${panelPort}/tcp
1324
+ ufw allow ${sshPort}/tcp
1325
+ ufw allow 39000:40000/tcp
1326
+ ufw_status=`ufw status`
1327
+ echo y|ufw enable
1328
+ ufw default deny
1329
+ ufw reload
1330
+ fi
1331
+ else
1332
+ if [ -f "/etc/init.d/iptables" ];then
1333
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 20 -j ACCEPT
1334
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
1335
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
1336
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
1337
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
1338
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ${panelPort} -j ACCEPT
1339
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ${sshPort} -j ACCEPT
1340
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 39000:40000 -j ACCEPT
1341
+ #iptables -I INPUT -p tcp -m state --state NEW -m udp --dport 39000:40000 -j ACCEPT
1342
+ iptables -A INPUT -p icmp --icmp-type any -j ACCEPT
1343
+ iptables -A INPUT -s localhost -d localhost -j ACCEPT
1344
+ iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
1345
+ iptables -P INPUT DROP
1346
+ service iptables save
1347
+ sed -i "s#IPTABLES_MODULES=\"\"#IPTABLES_MODULES=\"ip_conntrack_netbios_ns ip_conntrack_ftp ip_nat_ftp\"#" /etc/sysconfig/iptables-config
1348
+ iptables_status=$(service iptables status | grep 'not running')
1349
+ if [ "${iptables_status}" == '' ];then
1350
+ service iptables restart
1351
+ fi
1352
+ else
1353
+ AliyunCheck=$(cat /etc/redhat-release|grep "Aliyun Linux")
1354
+ [ "${AliyunCheck}" ] && return
1355
+ yum install firewalld -y
1356
+ [ "${Centos8Check}" ] && yum reinstall python3-six -y
1357
+ systemctl enable firewalld
1358
+ systemctl start firewalld
1359
+ firewall-cmd --set-default-zone=public > /dev/null 2>&1
1360
+ firewall-cmd --permanent --zone=public --add-port=20/tcp > /dev/null 2>&1
1361
+ firewall-cmd --permanent --zone=public --add-port=21/tcp > /dev/null 2>&1
1362
+ firewall-cmd --permanent --zone=public --add-port=22/tcp > /dev/null 2>&1
1363
+ firewall-cmd --permanent --zone=public --add-port=80/tcp > /dev/null 2>&1
1364
+ firewall-cmd --permanent --zone=public --add-port=443/tcp > /dev/null 2>&1
1365
+ firewall-cmd --permanent --zone=public --add-port=${panelPort}/tcp > /dev/null 2>&1
1366
+ firewall-cmd --permanent --zone=public --add-port=${sshPort}/tcp > /dev/null 2>&1
1367
+ firewall-cmd --permanent --zone=public --add-port=39000-40000/tcp > /dev/null 2>&1
1368
+ #firewall-cmd --permanent --zone=public --add-port=39000-40000/udp > /dev/null 2>&1
1369
+ firewall-cmd --reload
1370
+ fi
1371
+ fi
1372
+ }
1373
+ Get_Ip_Address(){
1374
+ getIpAddress=""
1375
+ #getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)
1376
+
1377
+ ipv4_address=""
1378
+ ipv6_address=""
1379
+
1380
+ ipv4_address=$(curl -4 -sS --connect-timeout 4 -m 5 https://api.bt.cn/Api/getIpAddress 2>&1)
1381
+ if [ -z "${ipv4_address}" ];then
1382
+ ipv4_address=$(curl -4 -sS --connect-timeout 4 -m 5 https://www.bt.cn/Api/getIpAddress 2>&1)
1383
+ if [ -z "${ipv4_address}" ];then
1384
+ ipv4_address=$(curl -4 -sS --connect-timeout 4 -m 5 https://www.aapanel.com/api/common/getClientIP 2>&1)
1385
+ fi
1386
+ fi
1387
+ IPV4_REGEX="^([0-9]{1,3}\.){3}[0-9]{1,3}$"
1388
+ if ! [[ $ipv4_address =~ $IPV4_REGEX ]]; then
1389
+ ipv4_address=""
1390
+ fi
1391
+
1392
+ ipv6_address=$(curl -6 -sS --connect-timeout 4 -m 5 https://www.bt.cn/Api/getIpAddress 2>&1)
1393
+ IPV6_REGEX="^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$"
1394
+ if ! [[ $ipv6_address =~ $IPV6_REGEX ]]; then
1395
+ ipv6_address=""
1396
+ else
1397
+ if [[ ! $ipv6_address =~ ^\[ ]]; then
1398
+ ipv6_address="[$ipv6_address]"
1399
+ fi
1400
+ fi
1401
+
1402
+ if [ "${ipv4_address}" ];then
1403
+ getIpAddress=$ipv4_address
1404
+ elif [ "${ipv6_address}" ];then
1405
+ getIpAddress=$ipv6_address
1406
+ fi
1407
+
1408
+
1409
+ if [ -z "${getIpAddress}" ] || [ "${getIpAddress}" = "0.0.0.0" ]; then
1410
+ isHosts=$(cat /etc/hosts|grep 'www.bt.cn')
1411
+ if [ -z "${isHosts}" ];then
1412
+ echo "" >> /etc/hosts
1413
+ echo "116.213.43.206 www.bt.cn" >> /etc/hosts
1414
+ getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)
1415
+ if [ -z "${getIpAddress}" ];then
1416
+ sed -i "/bt.cn/d" /etc/hosts
1417
+ fi
1418
+ fi
1419
+ fi
1420
+
1421
+ CN_CHECK=$(curl -sS --connect-timeout 10 -m 10 https://api.bt.cn/api/isCN)
1422
+ if [ "${CN_CHECK}" == "True" ];then
1423
+ echo "True" > /www/server/panel/data/domestic_ip.pl
1424
+ else
1425
+ echo "True" > /www/server/panel/data/foreign_ip.pl
1426
+ fi
1427
+
1428
+ ipv4Check=$($python_bin -c "import re; print(re.match('^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$','${getIpAddress}'))")
1429
+ if [ "${ipv4Check}" == "None" ];then
1430
+ ipv6Address=$(echo ${getIpAddress}|tr -d "[]")
1431
+ ipv6Check=$($python_bin -c "import re; print(re.match('^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$','${ipv6Address}'))")
1432
+ if [ "${ipv6Check}" == "None" ]; then
1433
+ getIpAddress="SERVER_IP"
1434
+ else
1435
+ echo "True" > ${setup_path}/server/panel/data/ipv6.pl
1436
+ sleep 1
1437
+ /etc/init.d/bt restart
1438
+ getIpAddress=$(echo "[$getIpAddress]")
1439
+ fi
1440
+ fi
1441
+
1442
+ if [ "${getIpAddress}" != "SERVER_IP" ];then
1443
+ echo "${getIpAddress}" > ${setup_path}/server/panel/data/iplist.txt
1444
+ fi
1445
+ LOCAL_IP=$(ip addr | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -E -v "^127\.|^255\.|^0\." | head -n 1)
1446
+ }
1447
+ Setup_Count(){
1448
+ curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/SetupCount?type=Linux\&o=$1 > /dev/null 2>&1
1449
+ if [ "$1" != "" ];then
1450
+ echo $1 > /www/server/panel/data/o.pl
1451
+ cd /www/server/panel
1452
+ $python_bin tools.py o
1453
+ fi
1454
+ echo /www > /var/bt_setupPath.conf
1455
+ }
1456
+ Start_Count(){
1457
+ curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/SetupCountPre?type=Linux\&o=$1 > /dev/null 2>&1
1458
+ echo /www > /var/bt_setupPath.conf
1459
+ echo "check_certificate = off" >> /etc/wgetrc
1460
+ }
1461
+ Install_Main(){
1462
+ Ready_Check
1463
+ Start_Count "ed250616lt"
1464
+ Set_Ssl
1465
+ startTime=`date +%s`
1466
+ Lock_Clear
1467
+ System_Check
1468
+ Get_Pack_Manager
1469
+ Set_Repo_Url
1470
+ get_node_url
1471
+
1472
+ MEM_TOTAL=$(free -g|grep Mem|awk '{print $2}')
1473
+ if [ "${MEM_TOTAL}" -le "1" ];then
1474
+ Auto_Swap
1475
+ fi
1476
+
1477
+ if [ "${PM}" = "yum" ]; then
1478
+ Install_RPM_Pack
1479
+ elif [ "${PM}" = "apt-get" ]; then
1480
+ Install_Deb_Pack
1481
+ fi
1482
+
1483
+ Install_Python_Lib
1484
+ Install_Bt
1485
+
1486
+
1487
+ Set_Bt_Panel
1488
+ Service_Add
1489
+ Set_Firewall
1490
+
1491
+ Get_Ip_Address
1492
+ Setup_Count "ed250616lt"
1493
+ Add_lib_Install
1494
+ }
1495
+
1496
+ echo "
1497
+ +----------------------------------------------------------------------
1498
+ | Bt-WebPanel FOR CentOS/Ubuntu/Debian
1499
+ +----------------------------------------------------------------------
1500
+ | Copyright © 2015-2099 BT-SOFT(http://www.bt.cn) All rights reserved.
1501
+ +----------------------------------------------------------------------
1502
+ | The WebPanel URL will be http://SERVER_IP:${panelPort} when installed.
1503
+ +----------------------------------------------------------------------
1504
+ | 为了您的正常使用,请确保使用全新或纯净的系统安装宝塔面板,不支持已部署项目/环境的系统安装
1505
+ +----------------------------------------------------------------------
1506
+ "
1507
+
1508
+
1509
+ while [ ${#} -gt 0 ]; do
1510
+ case $1 in
1511
+ -u|--user)
1512
+ PANEL_USER=$2
1513
+ shift 1
1514
+ ;;
1515
+ -p|--password)
1516
+ PANEL_PASSWORD=$2
1517
+ shift 1
1518
+ ;;
1519
+ -P|--port)
1520
+ PANEL_PORT=$2
1521
+ shift 1
1522
+ ;;
1523
+ --safe-path)
1524
+ SAFE_PATH=$2
1525
+ shift 1
1526
+ ;;
1527
+ --ssl-disable)
1528
+ SSL_PL="disable"
1529
+ ;;
1530
+ -y)
1531
+ go="y"
1532
+ ;;
1533
+ *)
1534
+ IDC_CODE=$1
1535
+ ;;
1536
+ esac
1537
+ shift 1
1538
+ done
1539
+
1540
+
1541
+ # Non-interactive default: proceed with installation unless explicitly set otherwise
1542
+ if [ -z "$go" ];then
1543
+ go="y"
1544
+ fi
1545
+
1546
+ if [ "$go" == 'n' ];then
1547
+ exit;
1548
+ fi
1549
+
1550
+ if [ -f "/www/server/panel/BT-Panel" ];then
1551
+ AAPANEL_CHECK=$(grep www.aapanel.com /www/server/panel/BT-Panel)
1552
+ if [ "${AAPANEL_CHECK}" ];then
1553
+ echo -e "----------------------------------------------------"
1554
+ echo -e "检查已安装有aapanel,无法进行覆盖安装宝塔面板"
1555
+ echo -e "如继续执行安装将移去aapanel面板数据(备份至/www/server/aapanel路径) 全新安装宝塔面板"
1556
+ echo -e "aapanel is alreday installed,Can't install panel"
1557
+ echo -e "is install Baota panel, aapanel data will be removed (backed up to /www/server/aapanel)"
1558
+ echo -e "Beginning new Baota panel installation."
1559
+ echo -e "----------------------------------------------------"
1560
+ echo -e "已知风险/Enter yes to force installation"
1561
+ yes="yes"
1562
+ if [ "$yes" != "yes" ];then
1563
+ echo -e "------------"
1564
+ echo "取消安装"
1565
+ exit;
1566
+ fi
1567
+ bt stop
1568
+ sleep 1
1569
+ mv /www/server/panel /www/server/aapanel
1570
+ fi
1571
+ fi
1572
+
1573
+
1574
+ ARCH_LINUX=$(cat /etc/os-release |grep "Arch Linux")
1575
+ if [ "${ARCH_LINUX}" ] && [ -f "/usr/bin/pacman" ];then
1576
+ pacman -Sy
1577
+ pacman -S curl wget unzip firewalld openssl pkg-config make gcc cmake libxml2 libxslt libvpx gd libsodium oniguruma sqlite libzip autoconf inetutils sudo --noconfirm
1578
+ fi
1579
+
1580
+ CURL_CHECK=$(which curl)
1581
+ if [ "$?" == "0" ] && [ ! -f "/tmp/btpanel_err.pl" ];then
1582
+ getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)
1583
+ INSTALL_DATE=$(date +%Y%m%d)
1584
+ curl -sS --connect-timeout 3 -m 3 --request POST --url "https://www.bt.cn/Api/installationCount" --data "date=${INSTALL_DATE}" --data "status=0" --data "ip=${getIpAddress}" > /dev/null
1585
+ fi
1586
+
1587
+ Install_Main
1588
+
1589
+ PANEL_SSL=$(cat /www/server/panel/data/ssl.pl 2> /dev/null)
1590
+ if [ "${PANEL_SSL}" == "True" ];then
1591
+ HTTP_S="https"
1592
+ else
1593
+ HTTP_S="http"
1594
+ fi
1595
+
1596
+ echo "安装基础网站流量统计程序..."
1597
+ wget -O site_new_total.sh ${download_Url}/site_total/install.sh &> /dev/null
1598
+ bash site_new_total.sh &> /dev/null
1599
+ rm -f site_new_total.sh
1600
+ echo "安装基础网站流量统计程序完成"
1601
+
1602
+ echo > /www/server/panel/data/bind.pl
1603
+ echo -e "=================================================================="
1604
+ echo -e "\033[32mCongratulations! Installed successfully!\033[0m"
1605
+ echo -e "=============注意:首次打开面板浏览器将提示不安全================="
1606
+ echo -e ""
1607
+ echo -e " 请选择以下其中一种方式解决不安全提醒"
1608
+ echo -e " 1、下载证书,地址:https://dg2.bt.cn/ssl/baota_root.pfx,双击安装,密码【www.bt.cn】"
1609
+ echo -e " 2、点击【高级】-【继续访问】或【接受风险并继续】访问"
1610
+ echo -e " 教程:https://www.bt.cn/bbs/thread-117246-1-1.html"
1611
+ echo -e " mac用户请下载使用此证书:https://dg2.bt.cn/ssl/mac.crt"
1612
+ echo -e ""
1613
+ echo -e "========================面板账户登录信息=========================="
1614
+ echo -e ""
1615
+ echo -e " 【云服务器】请在安全组放行 $panelPort 端口"
1616
+ if [ -z "${ipv4_address}" ] && [ -z "${ipv6_address}" ];then
1617
+ echo -e " 外网面板地址: ${HTTP_S}://SERVER_IP:${panelPort}${auth_path}"
1618
+ fi
1619
+ if [ "${ipv4_address}" ];then
1620
+ echo -e " 外网ipv4面板地址: ${HTTP_S}://${ipv4_address}:${panelPort}${auth_path}"
1621
+ fi
1622
+ if [ "${ipv6_address}" ];then
1623
+ echo -e " 外网ipv6面板地址: ${HTTP_S}://${ipv6_address}:${panelPort}${auth_path}"
1624
+ fi
1625
+ echo -e " 内网面板地址: ${HTTP_S}://${LOCAL_IP}:${panelPort}${auth_path}"
1626
+ echo -e " username: $username"
1627
+ echo -e " password: $password"
1628
+ echo -e ""
1629
+ echo -e " 浏览器访问以下链接,添加宝塔客服"
1630
+ echo -e " https://www.bt.cn/new/wechat_customer"
1631
+ echo -e "=================================================================="
1632
+ endTime=`date +%s`
1633
+ ((outTime=($endTime-$startTime)/60))
1634
+ if [ "${outTime}" -le "5" ];then
1635
+ echo ${download_Url} > /www/server/panel/install/d_node.pl
1636
+ fi
1637
+ if [ "${outTime}" == "0" ];then
1638
+ ((outTime=($endTime-$startTime)))
1639
+ echo -e "Time consumed:\033[32m $outTime \033[0mseconds!"
1640
+ else
1641
+ echo -e "Time consumed:\033[32m $outTime \033[0mMinute!"
1642
+ fi
1643
+ if [ "${INSTALL_DATE}" ];then
1644
+ curl -sS --connect-timeout 5 -m 5 --request POST --url "https://www.bt.cn/Api/installationCount" --data "date=${INSTALL_DATE}" --data "status=1" --data "ip=${getIpAddress}" > /dev/null
1645
+ fi
1646
+
1647
+
1648
+