You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
5.6 KiB

1 year ago
10 months ago
1 year ago
10 months ago
1 year ago
10 months ago
1 year ago
10 months ago
1 year ago
11 months ago
1 year ago
10 months ago
8 months ago
7 months ago
10 months ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
8 months ago
1 year ago
  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. Btapi_Url='http://www.example.com'
  6. if [ ! -d /www/server/panel/BTPanel ];then
  7. echo "============================================="
  8. echo "错误, 5.x不可以使用此命令升级!"
  9. echo "5.9平滑升级到6.0的命令:curl http://download.bt.cn/install/update_to_6.sh|bash"
  10. exit 0;
  11. fi
  12. if [ ! -f "/www/server/panel/pyenv/bin/python3" ];then
  13. echo "============================================="
  14. echo "错误, 当前面板过旧/py-2.7/无pyenv环境,无法升级至最新版面板"
  15. echo "请截图发帖至论坛www.bt.cn/bbs求助"
  16. exit 0;
  17. fi
  18. Centos6Check=$(cat /etc/redhat-release | grep ' 6.' | grep -iE 'centos|Red Hat')
  19. if [ "${Centos6Check}" ];then
  20. echo "Centos6不支持升级宝塔面板,建议备份数据重装更换Centos7/8安装宝塔面板"
  21. exit 1
  22. fi
  23. public_file=/www/server/panel/install/public.sh
  24. if [ ! -f $public_file ];then
  25. wget -O Tpublic.sh $Btapi_Url/install/public.sh -T 20;
  26. fi
  27. . $public_file
  28. Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
  29. if [ "${Centos8Check}" ];then
  30. if [ ! -f "/usr/bin/python" ] && [ -f "/usr/bin/python3" ] && [ ! -d "/www/server/panel/pyenv" ]; then
  31. ln -sf /usr/bin/python3 /usr/bin/python
  32. fi
  33. fi
  34. mypip="pip"
  35. env_path=/www/server/panel/pyenv/bin/activate
  36. if [ -f $env_path ];then
  37. mypip="/www/server/panel/pyenv/bin/pip"
  38. fi
  39. download_Url=$NODE_URL
  40. setup_path=/www
  41. version=$(curl -Ss --connect-timeout 5 -m 2 $Btapi_Url/api/panel/get_version)
  42. if [ "$version" = '' ];then
  43. version='8.0.5'
  44. fi
  45. armCheck=$(uname -m|grep arm)
  46. if [ "${armCheck}" ];then
  47. version='7.7.0'
  48. fi
  49. if [ "$1" ];then
  50. version=$1
  51. fi
  52. wget -T 5 -O /tmp/panel.zip $Btapi_Url/install/update/LinuxPanel-${version}.zip
  53. dsize=$(du -b /tmp/panel.zip|awk '{print $1}')
  54. if [ $dsize -lt 10240 ];then
  55. echo "获取更新包失败,请稍后更新或联系宝塔运维"
  56. exit;
  57. fi
  58. unzip -o /tmp/panel.zip -d $setup_path/server/ > /dev/null
  59. rm -f /tmp/panel.zip
  60. cd $setup_path/server/panel/
  61. check_bt=`cat /etc/init.d/bt`
  62. if [ "${check_bt}" = "" ];then
  63. rm -f /etc/init.d/bt
  64. wget -O /etc/init.d/bt $download_Url/install/src/bt7.init -T 20
  65. chmod +x /etc/init.d/bt
  66. fi
  67. echo "=============================================================="
  68. echo "正在修复面板依赖问题"
  69. rm -f /www/server/panel/*.pyc
  70. rm -f /www/server/panel/class/*.pyc
  71. #pip install flask_sqlalchemy
  72. #pip install itsdangerous==0.24
  73. btpip install natsort
  74. pip_list=$($mypip list)
  75. request_v=$(btpip list 2>/dev/null|grep "requests "|awk '{print $2}'|cut -d '.' -f 2)
  76. if [ "$request_v" = "" ] || [ "${request_v}" -gt "28" ];then
  77. $mypip install requests==2.27.1
  78. fi
  79. openssl_v=$(echo "$pip_list"|grep pyOpenSSL)
  80. if [ "$openssl_v" = "" ];then
  81. $mypip install pyOpenSSL
  82. fi
  83. #cffi_v=$(echo "$pip_list"|grep cffi|grep 1.12.)
  84. #if [ "$cffi_v" = "" ];then
  85. # $mypip install cffi==1.12.3
  86. #fi
  87. pymysql=$(echo "$pip_list"|grep pymysql)
  88. if [ "$pymysql" = "" ];then
  89. $mypip install pymysql
  90. fi
  91. GEVENT_V=$(btpip list 2> /dev/null|grep "gevent "|awk '{print $2}'|cut -f 1 -d '.')
  92. if [ "${GEVENT_V}" -le "1" ];then
  93. /www/server/panel/pyenv/bin/pip3 install -I gevent
  94. fi
  95. BROTLI_C=$(btpip list 2> /dev/null |grep Brotli)
  96. if [ -z "$BROTLI_C" ]; then
  97. btpip install brotli
  98. fi
  99. PYMYSQL_C=$(btpip list 2> /dev/null |grep PyMySQL)
  100. if [ -z "$PYMYSQL_C" ]; then
  101. btpip install PyMySQL
  102. fi
  103. PY_CRPYT=$(btpip list 2> /dev/null |grep cryptography|awk '{print $2}'|cut -f 1 -d '.')
  104. if [ "${PY_CRPYT}" -le "10" ];then
  105. btpip install pyOpenSSL==24.1.0
  106. btpip install cryptography==42.0.5
  107. fi
  108. PYMYSQL_SSL_CHECK=$(btpython -c "import pymysql" 2>&1|grep "AttributeError: module 'cryptography.hazmat.bindings._rust.openssl'")
  109. if [ "${PYMYSQL_SSL_CHECK}" ];then
  110. btpip uninstall pyopenssl cryptography -y
  111. btpip install pyopenssl cryptography
  112. fi
  113. btpip uninstall enum34 -y
  114. btpip install geoip2==4.7.0
  115. btpip install pandas
  116. pymysql=$(echo "$pip_list"|grep pycryptodome)
  117. if [ "$pymysql" = "" ];then
  118. $mypip install pycryptodome
  119. fi
  120. echo "修复面板依赖完成!"
  121. echo "==========================================="
  122. #psutil=$(echo "$pip_list"|grep psutil|awk '{print $2}'|grep '5.7.')
  123. #if [ "$psutil" = "" ];then
  124. # $mypip install -U psutil
  125. #fi
  126. if [ -d /www/server/panel/class/BTPanel ];then
  127. rm -rf /www/server/panel/class/BTPanel
  128. fi
  129. rm -f /www/server/panel/class/*.so
  130. if [ ! -f /www/server/panel/data/not_workorder.pl ]; then
  131. echo "True" > /www/server/panel/data/not_workorder.pl
  132. fi
  133. if [ ! -f /www/server/panel/data/userInfo.json ]; then
  134. echo "{\"uid\":1,\"username\":\"Administrator\",\"address\":\"127.0.0.1\",\"serverid\":\"1\",\"access_key\":\"test\",\"secret_key\":\"123456\",\"ukey\":\"123456\",\"state\":1}" > /www/server/panel/data/userInfo.json
  135. fi
  136. if [ ! -f /www/server/panel/data/panel_nps.pl ]; then
  137. echo "" > /www/server/panel/data/panel_nps.pl
  138. fi
  139. if [ ! -f /www/server/panel/data/btwaf_nps.pl ]; then
  140. echo "" > /www/server/panel/data/btwaf_nps.pl
  141. fi
  142. if [ ! -f /www/server/panel/data/tamper_proof_nps.pl ]; then
  143. echo "" > /www/server/panel/data/tamper_proof_nps.pl
  144. fi
  145. if [ ! -f /www/server/panel/data/total_nps.pl ]; then
  146. echo "" > /www/server/panel/data/total_nps.pl
  147. fi
  148. echo "==========================================="
  149. echo "正在更新面板文件..............."
  150. sleep 1
  151. echo "更新完成!"
  152. echo "==========================================="
  153. chattr -i /etc/init.d/bt
  154. chmod +x /etc/init.d/bt
  155. echo "====================================="
  156. rm -f /dev/shm/bt_sql_tips.pl
  157. kill $(ps aux|grep -E "task.pyc|main.py"|grep -v grep|awk '{print $2}')
  158. /etc/init.d/bt restart
  159. echo 'True' > /www/server/panel/data/restart.pl
  160. pkill -9 gunicorn &
  161. echo "已成功升级到[$version]${Ver}";