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.

209 lines
6.0 KiB

1 year ago
10 months ago
1 year ago
4 months ago
1 year ago
4 months ago
1 year ago
10 months ago
1 year ago
10 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
10 months ago
8 months ago
8 months ago
10 months ago
6 months ago
1 year ago
10 months ago
6 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. Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
  24. if [ "${Centos8Check}" ];then
  25. if [ ! -f "/usr/bin/python" ] && [ -f "/usr/bin/python3" ] && [ ! -d "/www/server/panel/pyenv" ]; then
  26. ln -sf /usr/bin/python3 /usr/bin/python
  27. fi
  28. fi
  29. mypip="pip"
  30. env_path=/www/server/panel/pyenv/bin/activate
  31. if [ -f $env_path ];then
  32. mypip="/www/server/panel/pyenv/bin/pip"
  33. fi
  34. if [ -f "/www/server/panel/data/down_url.pl" ];then
  35. D_NODE_URL=$(cat /www/server/panel/data/down_url.pl|grep bt.cn)
  36. fi
  37. if [ -z "${D_NODE_URL}" ];then
  38. D_NODE_URL="download.bt.cn"
  39. fi
  40. download_Url=$D_NODE_URL
  41. setup_path=/www
  42. version=$(curl -Ss --connect-timeout 5 -m 2 $Btapi_Url/api/panel/get_version)
  43. if [ -z "$VERSION_CHECK" ];then
  44. version='9.1.0'
  45. fi
  46. armCheck=$(uname -m|grep arm)
  47. if [ "${armCheck}" ];then
  48. version='7.7.0'
  49. fi
  50. if [ "$1" ];then
  51. version=$1
  52. fi
  53. wget -T 5 -O /tmp/panel.zip $Btapi_Url/install/update/LinuxPanel-${version}.zip
  54. dsize=$(du -b /tmp/panel.zip|awk '{print $1}')
  55. if [ $dsize -lt 10240 ];then
  56. echo "获取更新包失败,请稍后更新或联系宝塔运维"
  57. exit;
  58. fi
  59. unzip -o /tmp/panel.zip -d $setup_path/server/ > /dev/null
  60. rm -f /tmp/panel.zip
  61. cd $setup_path/server/panel/
  62. check_bt=`cat /etc/init.d/bt`
  63. if [ "${check_bt}" = "" ];then
  64. rm -f /etc/init.d/bt
  65. wget -O /etc/init.d/bt $download_Url/install/src/bt7.init -T 20
  66. chmod +x /etc/init.d/bt
  67. fi
  68. echo "=============================================================="
  69. echo "正在修复面板依赖问题"
  70. rm -f /www/server/panel/*.pyc
  71. rm -f /www/server/panel/class/*.pyc
  72. #pip install flask_sqlalchemy
  73. #pip install itsdangerous==0.24
  74. pip_list=$($mypip list 2>&1)
  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. NATSORT_C=$(echo $pip_list|grep natsort)
  80. if [ -z "${NATSORT_C}" ];then
  81. btpip install natsort
  82. fi
  83. openssl_v=$(echo "$pip_list"|grep pyOpenSSL)
  84. if [ "$openssl_v" = "" ];then
  85. $mypip install pyOpenSSL
  86. fi
  87. #cffi_v=$(echo "$pip_list"|grep cffi|grep 1.12.)
  88. #if [ "$cffi_v" = "" ];then
  89. # $mypip install cffi==1.12.3
  90. #fi
  91. pymysql=$(echo "$pip_list"|grep pymysql)
  92. if [ "$pymysql" = "" ];then
  93. $mypip install pymysql
  94. fi
  95. GEVENT_V=$(btpip list 2> /dev/null|grep "gevent "|awk '{print $2}'|cut -f 1 -d '.')
  96. if [ "${GEVENT_V}" -le "1" ];then
  97. /www/server/panel/pyenv/bin/pip3 install -I gevent
  98. fi
  99. BROTLI_C=$(btpip list 2> /dev/null |grep Brotli)
  100. if [ -z "$BROTLI_C" ]; then
  101. btpip install brotli
  102. fi
  103. PYMYSQL_C=$(btpip list 2> /dev/null |grep PyMySQL)
  104. if [ -z "$PYMYSQL_C" ]; then
  105. btpip install PyMySQL
  106. fi
  107. PY_CRPYT=$(btpip list 2> /dev/null |grep cryptography|awk '{print $2}'|cut -f 1 -d '.')
  108. if [ "${PY_CRPYT}" -le "10" ];then
  109. btpip install pyOpenSSL==24.1.0
  110. btpip install cryptography==42.0.5
  111. fi
  112. PYMYSQL_SSL_CHECK=$(btpython -c "import pymysql" 2>&1|grep "AttributeError: module 'cryptography.hazmat.bindings._rust.openssl'")
  113. if [ "${PYMYSQL_SSL_CHECK}" ];then
  114. btpip uninstall pyopenssl cryptography -y
  115. btpip install pyopenssl cryptography
  116. fi
  117. btpip uninstall enum34 -y
  118. GEOIP_C=$(echo $pip_list|grep geoip2)
  119. if [ -z "${GEOIP_C}" ];then
  120. btpip install geoip2==4.7.0
  121. fi
  122. PANDAS_C=$(echo $pip_list|grep pandas)
  123. if [ -z "${PANDAS_C}" ];then
  124. btpip install pandas
  125. fi
  126. pymysql=$(echo "$pip_list"|grep pycryptodome)
  127. if [ "$pymysql" = "" ];then
  128. $mypip install pycryptodome
  129. fi
  130. echo "修复面板依赖完成!"
  131. echo "==========================================="
  132. RE_UPDATE=$(cat /www/server/panel/data/db/update)
  133. if [ "$RE_UPDATE" -ge "4" ];then
  134. echo "2" > /www/server/panel/data/db/update
  135. fi
  136. #psutil=$(echo "$pip_list"|grep psutil|awk '{print $2}'|grep '5.7.')
  137. #if [ "$psutil" = "" ];then
  138. # $mypip install -U psutil
  139. #fi
  140. if [ -d /www/server/panel/class/BTPanel ];then
  141. rm -rf /www/server/panel/class/BTPanel
  142. fi
  143. rm -f /www/server/panel/class/*.so
  144. if [ ! -f /www/server/panel/data/not_workorder.pl ]; then
  145. echo "True" > /www/server/panel/data/not_workorder.pl
  146. fi
  147. if [ ! -f /www/server/panel/data/userInfo.json ]; then
  148. 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
  149. fi
  150. if [ ! -f /www/server/panel/data/panel_nps.pl ]; then
  151. echo "" > /www/server/panel/data/panel_nps.pl
  152. fi
  153. if [ ! -f /www/server/panel/data/btwaf_nps.pl ]; then
  154. echo "" > /www/server/panel/data/btwaf_nps.pl
  155. fi
  156. if [ ! -f /www/server/panel/data/tamper_proof_nps.pl ]; then
  157. echo "" > /www/server/panel/data/tamper_proof_nps.pl
  158. fi
  159. if [ ! -f /www/server/panel/data/total_nps.pl ]; then
  160. echo "" > /www/server/panel/data/total_nps.pl
  161. fi
  162. echo "==========================================="
  163. echo "正在更新面板文件..............."
  164. sleep 1
  165. echo "更新完成!"
  166. echo "==========================================="
  167. chattr -i /etc/init.d/bt
  168. chmod +x /etc/init.d/bt
  169. echo "====================================="
  170. rm -f /dev/shm/bt_sql_tips.pl
  171. kill $(ps aux|grep -E "task.pyc|main.py"|grep -v grep|awk '{print $2}')
  172. /etc/init.d/bt restart
  173. echo 'True' > /www/server/panel/data/restart.pl
  174. pkill -9 gunicorn &
  175. echo "已成功升级到[$version]${Ver}";