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.

205 lines
5.9 KiB

1 year ago
10 months ago
1 year ago
6 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. 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.2.0'
  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. pip_list=$($mypip list 2>&1)
  74. request_v=$(btpip list 2>/dev/null|grep "requests "|awk '{print $2}'|cut -d '.' -f 2)
  75. if [ "$request_v" = "" ] || [ "${request_v}" -gt "28" ];then
  76. $mypip install requests==2.27.1
  77. fi
  78. NATSORT_C=$(echo $pip_list|grep natsort)
  79. if [ -z "${NATSORT_C}" ];then
  80. btpip install natsort
  81. fi
  82. openssl_v=$(echo "$pip_list"|grep pyOpenSSL)
  83. if [ "$openssl_v" = "" ];then
  84. $mypip install pyOpenSSL
  85. fi
  86. #cffi_v=$(echo "$pip_list"|grep cffi|grep 1.12.)
  87. #if [ "$cffi_v" = "" ];then
  88. # $mypip install cffi==1.12.3
  89. #fi
  90. pymysql=$(echo "$pip_list"|grep pymysql)
  91. if [ "$pymysql" = "" ];then
  92. $mypip install pymysql
  93. fi
  94. GEVENT_V=$(btpip list 2> /dev/null|grep "gevent "|awk '{print $2}'|cut -f 1 -d '.')
  95. if [ "${GEVENT_V}" -le "1" ];then
  96. /www/server/panel/pyenv/bin/pip3 install -I gevent
  97. fi
  98. BROTLI_C=$(btpip list 2> /dev/null |grep Brotli)
  99. if [ -z "$BROTLI_C" ]; then
  100. btpip install brotli
  101. fi
  102. PYMYSQL_C=$(btpip list 2> /dev/null |grep PyMySQL)
  103. if [ -z "$PYMYSQL_C" ]; then
  104. btpip install PyMySQL
  105. fi
  106. PY_CRPYT=$(btpip list 2> /dev/null |grep cryptography|awk '{print $2}'|cut -f 1 -d '.')
  107. if [ "${PY_CRPYT}" -le "10" ];then
  108. btpip install pyOpenSSL==24.1.0
  109. btpip install cryptography==42.0.5
  110. fi
  111. PYMYSQL_SSL_CHECK=$(btpython -c "import pymysql" 2>&1|grep "AttributeError: module 'cryptography.hazmat.bindings._rust.openssl'")
  112. if [ "${PYMYSQL_SSL_CHECK}" ];then
  113. btpip uninstall pyopenssl cryptography -y
  114. btpip install pyopenssl cryptography
  115. fi
  116. btpip uninstall enum34 -y
  117. GEOIP_C=$(echo $pip_list|grep geoip2)
  118. if [ -z "${GEOIP_C}" ];then
  119. btpip install geoip2==4.7.0
  120. fi
  121. PANDAS_C=$(echo $pip_list|grep pandas)
  122. if [ -z "${PANDAS_C}" ];then
  123. btpip install pandas
  124. fi
  125. pymysql=$(echo "$pip_list"|grep pycryptodome)
  126. if [ "$pymysql" = "" ];then
  127. $mypip install pycryptodome
  128. fi
  129. echo "修复面板依赖完成!"
  130. echo "==========================================="
  131. RE_UPDATE=$(cat /www/server/panel/data/db/update)
  132. if [ "$RE_UPDATE" -ge "4" ];then
  133. echo "2" > /www/server/panel/data/db/update
  134. fi
  135. #psutil=$(echo "$pip_list"|grep psutil|awk '{print $2}'|grep '5.7.')
  136. #if [ "$psutil" = "" ];then
  137. # $mypip install -U psutil
  138. #fi
  139. if [ -d /www/server/panel/class/BTPanel ];then
  140. rm -rf /www/server/panel/class/BTPanel
  141. fi
  142. rm -f /www/server/panel/class/*.so
  143. if [ ! -f /www/server/panel/data/not_workorder.pl ]; then
  144. echo "True" > /www/server/panel/data/not_workorder.pl
  145. fi
  146. if [ ! -f /www/server/panel/data/userInfo.json ]; then
  147. 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
  148. fi
  149. if [ ! -f /www/server/panel/data/panel_nps.pl ]; then
  150. echo "" > /www/server/panel/data/panel_nps.pl
  151. fi
  152. if [ ! -f /www/server/panel/data/btwaf_nps.pl ]; then
  153. echo "" > /www/server/panel/data/btwaf_nps.pl
  154. fi
  155. if [ ! -f /www/server/panel/data/tamper_proof_nps.pl ]; then
  156. echo "" > /www/server/panel/data/tamper_proof_nps.pl
  157. fi
  158. if [ ! -f /www/server/panel/data/total_nps.pl ]; then
  159. echo "" > /www/server/panel/data/total_nps.pl
  160. fi
  161. echo "==========================================="
  162. echo "正在更新面板文件..............."
  163. sleep 1
  164. echo "更新完成!"
  165. echo "==========================================="
  166. chattr -i /etc/init.d/bt
  167. chmod +x /etc/init.d/bt
  168. echo "====================================="
  169. rm -f /dev/shm/bt_sql_tips.pl
  170. kill $(ps aux|grep -E "task.pyc|main.py"|grep -v grep|awk '{print $2}')
  171. /etc/init.d/bt restart
  172. echo 'True' > /www/server/panel/data/restart.pl
  173. pkill -9 gunicorn &
  174. echo "已成功升级到[$version]${Ver}";