Add files via upload

pull/5/head
dostume 2022-11-02 01:49:31 +08:00 committed by GitHub
parent 9e1db19db2
commit 260406f8c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 171 additions and 0 deletions

65
optimize.sh Normal file
View File

@ -0,0 +1,65 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
if [ $(whoami) != "root" ];then
echo "请使用root权限执行命令"
exit 1;
fi
if [ ! -d /www/server/panel ] || [ ! -f /etc/init.d/bt ];then
echo "未安装宝塔面板"
exit 1
fi
if [ ! -f /www/server/panel/data/userInfo.json ]; then
echo "{\"uid\":1000,\"username\":\"admin\",\"serverid\":1}" > /www/server/panel/data/userInfo.json
fi
echo "已去除宝塔面板强制绑定账号."
Layout_file="/www/server/panel/BTPanel/templates/default/layout.html";
JS_file="/www/server/panel/BTPanel/static/bt.js";
if [ `grep -c "<script src=\"/static/bt.js\"></script>" $Layout_file` -eq '0' ];then
sed -i '/{% block scripts %} {% endblock %}/a <script src="/static/bt.js"></script>' $Layout_file;
fi;
wget -q http://f.cccyun.cc/bt/bt.js -O $JS_file;
echo "已去除各种计算题与延时等待."
sed -i "/htaccess = self.sitePath+'\/.htaccess'/, /public.ExecShell('chown -R www:www ' + htaccess)/d" /www/server/panel/class/panelSite.py
sed -i "/index = self.sitePath+'\/index.html'/, /public.ExecShell('chown -R www:www ' + index)/d" /www/server/panel/class/panelSite.py
sed -i "/doc404 = self.sitePath+'\/404.html'/, /public.ExecShell('chown -R www:www ' + doc404)/d" /www/server/panel/class/panelSite.py
echo "已去除创建网站自动创建的垃圾文件."
sed -i "s/root \/www\/server\/nginx\/html/return 400/" /www/server/panel/class/panelSite.py
if [ -f /www/server/panel/vhost/nginx/0.default.conf ]; then
sed -i "s/root \/www\/server\/nginx\/html/return 400/" /www/server/panel/vhost/nginx/0.default.conf
fi
echo "已关闭未绑定域名提示页面."
sed -i "s/return render_template('autherr.html')/return abort(404)/" /www/server/panel/BTPanel/__init__.py
echo "已关闭安全入口登录提示页面."
sed -i "/p = threading.Thread(target=check_files_panel)/, /p.start()/d" /www/server/panel/task.py
sed -i "/p = threading.Thread(target=check_panel_msg)/, /p.start()/d" /www/server/panel/task.py
echo "已去除消息推送与文件校验."
sed -i "/^logs_analysis()/d" /www/server/panel/script/site_task.py
sed -i "s/run_thread(cloud_check_domain,(domain,))/return/" /www/server/panel/class/public.py
echo "已去除面板日志与绑定域名上报."
if [ ! -f /www/server/panel/data/not_recommend.pl ]; then
echo "True" > /www/server/panel/data/not_recommend.pl
fi
if [ ! -f /www/server/panel/data/not_workorder.pl ]; then
echo "True" > /www/server/panel/data/not_workorder.pl
fi
echo "已关闭活动推荐与在线客服."
/etc/init.d/bt restart
echo -e "=================================================================="
echo -e "\033[32m宝塔面板优化脚本执行完毕\033[0m"
echo -e "=================================================================="
echo "适用宝塔面板版本7.7"
echo "如需还原之前的样子,请在面板首页点击“修复”"
echo -e "=================================================================="

106
update6.sh Normal file
View File

@ -0,0 +1,106 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
LANG=en_US.UTF-8
if [ ! -d /www/server/panel/BTPanel ];then
echo "============================================="
echo "错误, 5.x不可以使用此命令升级!"
echo "5.9平滑升级到6.0的命令curl http://download.bt.cn/install/update_to_6.sh|bash"
exit 0;
fi
public_file=/www/server/panel/install/public.sh
publicFileMd5=$(md5sum ${public_file} 2>/dev/null|awk '{print $1}')
md5check="acfc18417ee58c64ff99d186f855e3e1"
if [ "${publicFileMd5}" != "${md5check}" ]; then
wget -O Tpublic.sh http://download.bt.cn/install/public.sh -T 20;
publicFileMd5=$(md5sum Tpublic.sh 2>/dev/null|awk '{print $1}')
if [ "${publicFileMd5}" == "${md5check}" ]; then
\cp -rpa Tpublic.sh $public_file
fi
rm -f Tpublic.sh
fi
. $public_file
Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
if [ "${Centos8Check}" ];then
if [ ! -f "/usr/bin/python" ] && [ -f "/usr/bin/python3" ] && [ ! -d "/www/server/panel/pyenv" ]; then
ln -sf /usr/bin/python3 /usr/bin/python
fi
fi
mypip="pip"
env_path=/www/server/panel/pyenv/bin/activate
if [ -f $env_path ];then
mypip="/www/server/panel/pyenv/bin/pip"
fi
download_Url=$NODE_URL
setup_path=/www
version='7.7.0'
wget -T 5 -O /tmp/panel.zip $download_Url/install/update/LinuxPanel-${version}.zip
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
rm -f /tmp/panel.zip
cd $setup_path/server/panel/
check_bt=`cat /etc/init.d/bt`
if [ "${check_bt}" = "" ];then
rm -f /etc/init.d/bt
wget -O /etc/init.d/bt $download_Url/install/src/bt6.init -T 20
chmod +x /etc/init.d/bt
fi
rm -f /www/server/panel/*.pyc
rm -f /www/server/panel/class/*.pyc
#pip install flask_sqlalchemy
#pip install itsdangerous==0.24
pip_list=$($mypip list)
request_v=$(echo "$pip_list"|grep requests)
if [ "$request_v" = "" ];then
$mypip install requests
fi
openssl_v=$(echo "$pip_list"|grep pyOpenSSL)
if [ "$openssl_v" = "" ];then
$mypip install pyOpenSSL
fi
#cffi_v=$(echo "$pip_list"|grep cffi|grep 1.12.)
#if [ "$cffi_v" = "" ];then
# $mypip install cffi==1.12.3
#fi
pymysql=$(echo "$pip_list"|grep pymysql)
if [ "$pymysql" = "" ];then
$mypip install pymysql
fi
pymysql=$(echo "$pip_list"|grep pycryptodome)
if [ "$pymysql" = "" ];then
$mypip install pycryptodome
fi
#psutil=$(echo "$pip_list"|grep psutil|awk '{print $2}'|grep '5.7.')
#if [ "$psutil" = "" ];then
# $mypip install -U psutil
#fi
if [ -d /www/server/panel/class/BTPanel ];then
rm -rf /www/server/panel/class/BTPanel
fi
chattr -i /etc/init.d/bt
chmod +x /etc/init.d/bt
echo "====================================="
rm -f /dev/shm/bt_sql_tips.pl
kill $(ps aux|grep -E "task.pyc|main.py"|grep -v grep|awk '{print $2}')
/etc/init.d/bt restart
echo 'True' > /www/server/panel/data/restart.pl
pkill -9 gunicorn &
echo "已成功升级到[$version]${Ver}";