-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate_panel_upx.sh
More file actions
463 lines (417 loc) · 14.4 KB
/
update_panel_upx.sh
File metadata and controls
463 lines (417 loc) · 14.4 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
pyenv_bin=/www/server/panel/pyenv/bin
# 通用下载链接
dlco=https://github.com/sweetsky123/btpanel/releases/download/common/
# ${dlco}
# 11.0下载链接
dl11=https://github.com/sweetsky123/btpanel/releases/download/11.0/
# ${dl11}
# 11.4下载链接
dl14=https://github.com/sweetsky123/btpanel/releases/download/11.0/
# ${dl14}
# lastest下载链接
dllt=https://github.com/sweetsky123/btpanel/releases/latest/download/
# ${dllt}
rep_path=${pyenv_bin}:$PATH
if [ -d "$pyenv_bin" ];then
PATH=$rep_path
fi
export PATH
LANG=en_US.UTF-8
Font_Yellow='\033[1;33m'
Font_Suffix='\033[0m'
setup_path=/www
is64bit=$(getconf LONG_BIT)
if [ "${is64bit}" != '64' ];then
echo "抱歉, 面板新版本不再支持32位系统, 无法进行升级";
echo "退出、不做任何操作"
exit 1
fi
Centos6Check=$(cat /etc/redhat-release | grep ' 6.' | grep -iE 'centos|Red Hat')
if [ "${Centos6Check}" ];then
echo "Centos6不支持升级宝塔面板,建议备份数据重装更换Centos7/8安装宝塔面板"
exit 1
fi
up_plugin=0
download_file(){
dst_file=$1
tmp_file=/tmp/bt_tmp_file.temp
if [ -f $tmp_file ];then
rm -f $tmp_file
fi
wget -O ${tmp_file} $2 -T 20
tmp_size=$(du -b $tmp_file|awk '{print $1}')
if [ $tmp_size -lt 10 ];then
echo "|-文件下载失败 $dst_file"
return
fi
if [ -f $dst_file ];then
rm -f $dst_file
fi
mv -f $tmp_file $dst_file
if [ -f $tmp_file ];then
rm -f $tmp_file
fi
}
Red_Error(){
echo '=================================================';
printf '\033[1;31;40m%b\033[0m\n' "$1";
exit 0;
}
check_panel(){
if [ ! -d /www/server/panel/BTPanel ];then
up_plugin=1
fi
}
select_node(){
echo -e "跳过选择下载节点"
#public_file=/www/server/panel/install/public.sh
#if [ ! -f $public_file ];then
#download_file $public_file ${dlco}/public.sh
#fi
#publicFileMd5=$(md5sum ${public_file}|awk '{print $1}')
#md5check="db0bc4ee0d73c3772aa403338553ff77"
#if [ "${publicFileMd5}" != "${md5check}" ]; then
#download_file $public_file ${dlco}/public.sh
#fi
#. $public_file
download_Url=https:/download.bt.cn
#downloads_Url=http://io.bt.sb
}
get_version(){
if [ -n "$version" ]; then
return
fi
# version=$(curl -Ss --connect-timeout 5 -m 2 https://api.bt.sb/api/panel/get_version)
wget -O get_version ${dllt}/get_version
version=$(cat get_version)
rm -f get_version
if [ "$version" = '' ];then
version='11.4.0'
echo -e "无法获取到版本号,默认下载11.4.0版本"
fi
}
#if [ "$1" ];then
#version=$1
#fi
install_pack(){
if [ -f /usr/bin/yum ];then
yum install libcurl-devel libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y
else
apt install libcurl4-openssl-dev net-tools swig build-essential libffi-dev zlib1g-dev libbz2-dev libssl-dev libncurses-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libdb++-dev libpcap-dev xz-utils -y
fi
}
install_python(){
curl -Ss --connect-timeout 3 -m 60 ${dlco}/pip_select.sh
bash pip_select.sh
pyenv_path="/www/server/panel"
python_bin=$pyenv_path/pyenv/bin/python
if [ -f $pyenv_path/pyenv/bin/python ];then
is_err=$($pyenv_path/pyenv/bin/python3.7 -V 2>&1|grep 'Could not find platform')
if [ "$is_err" = "" ];then
chmod -R 700 $pyenv_path/pyenv/bin
is_package=$($python_bin -m psutil 2>&1|grep package)
if [ "$is_package" = "" ];then
wget -O $pyenv_path/pyenv/pip.txt ${dlco}/pip.txt -T 5
$pyenv_path/pyenv/bin/pip install -U pip
$pyenv_path/pyenv/bin/pip install -U setuptools
$pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.txt
fi
source $pyenv_path/pyenv/bin/activate
return
else
rm -rf $pyenv_path/pyenv
fi
fi
install_pack
py_version="3.7.9"
mkdir -p $pyenv_path
os_type='el'
os_version='7'
is_export_openssl=0
Get_Versions
Centos6_Openssl
Other_Openssl
echo "OS: $os_type - $os_version"
is_aarch64=$(uname -a|grep aarch64)
if [ "$is_aarch64" != "" ];then
os_version="aarch64"
fi
up_plugin=1
if [ -f "/www/server/panel/pymake.pl" ];then
os_version=""
rm -f /www/server/panel/pymake.pl
fi
if [ "${os_version}" != "" ];then
pyenv_file="/www/pyenv.tar.gz"
wget -O $pyenv_file ${dlco}/pyenv-${os_type}${os_version}-x64-upx.tar.gz -T 10
tmp_size=$(du -b $pyenv_file|awk '{print $1}')
if [ $tmp_size -lt 703460 ];then
rm -f $pyenv_file
echo "ERROR: Download python env fielded."
else
echo "Install python env..."
tar zxvf $pyenv_file -C $pyenv_path/ &> /dev/null
chmod -R 700 $pyenv_path/pyenv/bin
if [ ! -f $pyenv_path/pyenv/bin/python ];then
rm -f $pyenv_file
Red_Error "ERROR: Install python env fielded."
fi
is_err=$($pyenv_path/pyenv/bin/python3.7 -V 2>&1|grep 'Could not find platform')
if [ "$is_err" = "" ];then
rm -f $pyenv_file
ln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip
ln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython
sync_python_lib
source $pyenv_path/pyenv/bin/activate
return
else
rm -rf $pyenv_path/pyenv
fi
fi
fi
if [ -f /usr/local/openssl/lib/libssl.so ];then
export LDFLAGS="-L/usr/local/openssl/lib"
export CPPFLAGS="-I/usr/local/openssl/include"
export PKG_CONFIG_PATH="/usr/local/openssl/lib/pkgconfig"
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/openssl/lib" >> /etc/profile
source /etc/profile
fi
cd /www
python_src='/www/python_src.tar.xz'
python_src_path="/www/Python-${py_version}"
wget -O $python_src ${dlco}/Python-3.7.16.tar.xz -T 5
tmp_size=$(du -b $python_src|awk '{print $1}')
if [ $tmp_size -lt 10703460 ];then
rm -f $python_src
Red_Error "ERROR: Download python source code fielded."
fi
tar xvf $python_src
rm -f $python_src
cd $python_src_path
./configure --prefix=$pyenv_path/pyenv
make -j$cpu_cpunt
make install
if [ ! -f $pyenv_path/pyenv/bin/python3.7 ];then
rm -rf $python_src_path
Red_Error "ERROR: Make python env fielded."
fi
cd ~
rm -rf $python_src_path
#wget -O $pyenv_path/pyenv/bin/activate $download_Url/install/pyenv/activate.panel -T 5
#wget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip.txt -T 5
wget -O $pyenv_path/pyenv/bin/activate ${dlco}/activate.panel -T 5
wget -O $pyenv_path/pyenv/pip.txt ${dlco}/pip.txt -T 5
ln -sf $pyenv_path/pyenv/bin/pip3.7 $pyenv_path/pyenv/bin/pip
ln -sf $pyenv_path/pyenv/bin/python3.7 $pyenv_path/pyenv/bin/python
ln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip
ln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython
chmod -R 700 $pyenv_path/pyenv/bin
$pyenv_path/pyenv/bin/pip install -U pip
$pyenv_path/pyenv/bin/pip install -U setuptools
$pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.txt
sync_python_lib
source $pyenv_path/pyenv/bin/activate
}
sync_python_lib(){
pip_list=$(pip list 2>/dev/null|grep -v Package|grep -v '\-\-\-\-\-\-'|awk '{print $1}'|xargs)
$pyenv_path/pyenv/bin/pip install -U pip setuptools
$pyenv_path/pyenv/bin/pip install $pip_list
}
Other_Openssl(){
openssl_version=$(openssl version|grep -Eo '[0-9]\.[0-9]\.[0-9]')
if [ "$openssl_version" = '1.0.1' ] || [ "$openssl_version" = '1.0.0' ];then
opensslVersion="1.0.2r"
if [ ! -f "/usr/local/openssl/lib/libssl.so" ];then
cd /www
openssl_src_file=/www/openssl.tar.gz
# wget -O $openssl_src_file ${download_Url}/src/openssl-${opensslVersion}.tar.gz
wget -O $openssl_src_file ${dlco}/openssl-1.0.2r.tar.gz
tmp_size=$(du -b $openssl_src_file|awk '{print $1}')
if [ $tmp_size -lt 703460 ];then
rm -f $openssl_src_file
Red_Error "ERROR: Download openssl-1.0.2 source code fielded."
fi
tar -zxf $openssl_src_file
rm -f $openssl_src_file
cd openssl-${opensslVersion}
./config --openssldir=/usr/local/openssl zlib-dynamic shared
make -j${cpuCore}
make install
echo "/usr/local/openssl/lib" > /etc/ld.so.conf.d/zopenssl.conf
ldconfig
cd ..
rm -rf openssl-${opensslVersion}
is_export_openssl=1
cd ~
fi
fi
}
Insatll_Libressl(){
openssl_version=$(openssl version|grep -Eo '[0-9]\.[0-9]\.[0-9]')
if [ "$openssl_version" = '1.0.1' ] || [ "$openssl_version" = '1.0.0' ];then
opensslVersion="3.0.2"
cd /www
openssl_src_file=/www/openssl.tar.gz
# wget -O $openssl_src_file ${download_Url}/install/pyenv/libressl-${opensslVersion}.tar.gz
wget -O $openssl_src_file ${dlco}/libressl-${opensslVersion}-upx.tar.gz
tmp_size=$(du -b $openssl_src_file|awk '{print $1}')
if [ $tmp_size -lt 703460 ];then
rm -f $openssl_src_file
Red_Error "ERROR: Download libressl-$opensslVersion source code fielded."
fi
tar -zxf $openssl_src_file
rm -f $openssl_src_file
cd libressl-${opensslVersion}
./config –prefix=/usr/local/lib
make -j${cpuCore}
make install
ldconfig
ldconfig -v
cd ..
rm -rf libressl-${opensslVersion}
is_export_openssl=1
cd ~
fi
}
Centos6_Openssl(){
if [ "$os_type" != 'el' ];then
return
fi
if [ "$os_version" != '6' ];then
return
fi
echo 'Centos6 install openssl-1.0.2...'
openssl_rpm_file="/www/openssl.rpm"
# wget -O $openssl_rpm_file $download_Url/rpm/centos6/${is64bit}/bt-openssl102.rpm -T 10
wget -O $openssl_rpm_file ${dlco}/bt-openssl102.rpm -T 10
tmp_size=$(du -b $openssl_rpm_file|awk '{print $1}')
if [ $tmp_size -lt 102400 ];then
rm -f $openssl_rpm_file
Red_Error "ERROR: Download python env fielded."
fi
rpm -ivh $openssl_rpm_file
rm -f $openssl_rpm_file
is_export_openssl=1
}
Get_Versions(){
redhat_version_file="/etc/redhat-release"
deb_version_file="/etc/issue"
if [ -f $redhat_version_file ];then
os_type='el'
is_aliyunos=$(cat $redhat_version_file|grep Aliyun)
if [ "$is_aliyunos" != "" ];then
return
fi
os_version=$(cat $redhat_version_file|grep CentOS|grep -Eo '([0-9]+\.)+[0-9]+'|grep -Eo '^[0-9]')
if [ "${os_version}" = "5" ];then
os_version=""
fi
else
os_type='ubuntu'
os_version=$(cat $deb_version_file|grep Ubuntu|grep -Eo '([0-9]+\.)+[0-9]+'|grep -Eo '^[0-9]+')
if [ "${os_version}" = "" ];then
os_type='debian'
os_version=$(cat $deb_version_file|grep Debian|grep -Eo '([0-9]+\.)+[0-9]+'|grep -Eo '[0-9]+')
if [ "${os_version}" = "" ];then
os_version=$(cat $deb_version_file|grep Debian|grep -Eo '[0-9]+')
fi
if [ "${os_version}" = "8" ];then
os_version=""
fi
if [ "${is64bit}" = '32' ];then
os_version=""
fi
fi
fi
}
update_panel(){
#wget -T 5 -O /tmp/panel.zip $downloads_Url/install/update/LinuxPanel-${version}.zip
wget -T 5 -O /tmp/panel.zip ${dllt}/LinuxPanel-${version}.zip
chattr -i /www/server/panel/data/userInfo.json
dsize=$(du -b /tmp/panel.zip|awk '{print $1}')
if [ $dsize -lt 10240 ];then
echo "获取更新包失败!"
exit;
fi
unzip -o /tmp/panel.zip -d $setup_path/server/ > /dev/null 2>&1
rm -f /tmp/panel.zip
sed -i 's/[0-9\.]\+[ ]\+www.bt.cn//g' /etc/hosts
sed -i 's/[0-9\.]\+[ ]\+api.bt.sb//g' /etc/hosts
#wget -O /www/server/panel/data/softList.conf ${download_Url}/install/conf/softListtls10.conf
if [ "$version" = "11.0.0" ]; then
echo "检测到指定版本为11.0.0,正在下载新版 softList 配置..."
wget -O /www/server/panel/data/softList.conf ${dl11}/softListtls10.conf
fi
cd $setup_path/server/panel/
check_bt=`cat /etc/init.d/bt|grep BT-Task`
if [ "${check_bt}" = "" ];then
rm -f /etc/init.d/bt
wget -O /etc/init.d/bt ${dl11}/bt7.init -T 20
chmod +x /etc/init.d/bt
fi
rm -f /www/server/panel/*.pyc
rm -f /www/server/panel/class/*.pyc
if [ ! -f $setup_path/server/panel/config/config.json ];then
#wget -T 5 -O $setup_path/server/panel/config/config.json $download_Url/install/pyenv/config/config.json
#wget -T 5 -O $setup_path/server/panel/config/dns_api.json $download_Url/install/pyenv/config/dns_api.json
wget -T 5 -O $setup_path/server/panel/config/config.json ${dlco}/config.json
wget -T 5 -O $setup_path/server/panel/config/dns_api.json ${dlco}/dns_api.json
fi
# 修复11.5.0错误
echo -e "检测到指定版本为11.5.0,正在修复可能的pip依赖问题"
if [ "$version" = "11.5.0" ]; then
$pyenv_path/pyenv/bin/python3 -m pip install asn1crypto==1.5.1 cbor2==5.4.6
fi
chattr -i /etc/init.d/bt
chmod +x /etc/init.d/bt
# if [ $up_plugin = 1 ];then
# $pyenv_bin/python /www/server/panel/tools.py update_to6
# fi
}
update_start(){
clear
echo "====================================="
echo "开始升级宝塔Linux面板,请稍候..."
echo "====================================="
}
update_end(){
echo "====================================="
rm -f /dev/shm/bt_sql_tips.pl
#echo > /www/server/panel/data/bind.pl
rm -rf /www/server/panel/data/bind.pl
rm -rf /www/server/panel/class/pluginAuth.cpython-37m-aarch64-linux-gnu.so
rm -rf /www/server/panel/class/pluginAuth.cpython-37m-i386-linux-gnu.so
rm -rf /www/server/panel/class/pluginAuth.cpython-37m-loongarch64-linux-gnu.so
rm -rf /www/server/panel/class/pluginAuth.cpython-37m-x86_64-linux-gnu.so
rm -rf /www/server/panel/class/pluginAuth.cpython-310-aarch64-linux-gnu.so
rm -rf /www/server/panel/class/pluginAuth.cpython-310-x86_64-linux-gnu.so
rm -rf /www/server/panel/class/pluginAuth.so
#rm -rf /www/server/panel/class/pluginAuth.py
rm -rf /www/server/panel/class/libAuth.aarch64.so
rm -rf /www/server/panel/class/libAuth.glibc-2.14.x86_64.so
rm -rf /www/server/panel/class/libAuth.loongarch64.so
rm -rf /www/server/panel/class/libAuth.x86-64.so
rm -rf /www/server/panel/class/libAuth.x86.so
#rm -rf /www/server/panel/class/PluginLoader.aarch64.Python3.7.so
#rm -rf /www/server/panel/class/PluginLoader.i686.Python3.7.so
#rm -rf /www/server/panel/class/PluginLoader.loongarch64.Python3.7.so
#rm -rf /www/server/panel/class/PluginLoader.so
rm -rf /www/server/panel/class/PluginLoader.s390x.Python3.7.so
#rm -rf /www/server/panel/class/PluginLoader.x86_64.glibc214.Python3.7.so
#rm -rf /www/server/panel/class/PluginLoader.x86_64.Python3.7.so
rm -f /dev/shm/bt_sql_tips.pl
kill $(ps aux|grep -E "task.py|main.py"|grep -v grep|awk '{print $2}') &>/dev/null
bash /www/server/panel/init.sh start
echo 'True' > /www/server/panel/data/restart.pl
pkill -9 gunicorn &>/dev/null &
}
rm -rf /www/server/phpmyadmin/pma
update_start
check_panel
select_node
install_python
get_version
update_panel
update_end