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.

139 lines
4.1 KiB

1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year 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. public_file=/www/server/panel/install/public.sh
  19. if [ ! -f $public_file ];then
  20. wget -O Tpublic.sh $Btapi_Url/install/public.sh -T 20;
  21. fi
  22. . $public_file
  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. download_Url=$NODE_URL
  35. setup_path=/www
  36. version=$(curl -Ss --connect-timeout 5 -m 2 $Btapi_Url/api/panel/get_version)
  37. if [ "$version" = '' ];then
  38. version='8.0.1'
  39. fi
  40. armCheck=$(uname -m|grep arm)
  41. if [ "${armCheck}" ];then
  42. version='7.7.0'
  43. fi
  44. if [ "$1" ];then
  45. version=$1
  46. fi
  47. wget -T 5 -O /tmp/panel.zip $Btapi_Url/install/update/LinuxPanel-${version}.zip
  48. dsize=$(du -b /tmp/panel.zip|awk '{print $1}')
  49. if [ $dsize -lt 10240 ];then
  50. echo "获取更新包失败,请稍后更新或联系宝塔运维"
  51. exit;
  52. fi
  53. unzip -o /tmp/panel.zip -d $setup_path/server/ > /dev/null
  54. rm -f /tmp/panel.zip
  55. cd $setup_path/server/panel/
  56. check_bt=`cat /etc/init.d/bt`
  57. if [ "${check_bt}" = "" ];then
  58. rm -f /etc/init.d/bt
  59. wget -O /etc/init.d/bt $download_Url/install/src/bt7.init -T 20
  60. chmod +x /etc/init.d/bt
  61. fi
  62. rm -f /www/server/panel/*.pyc
  63. rm -f /www/server/panel/class/*.pyc
  64. #pip install flask_sqlalchemy
  65. #pip install itsdangerous==0.24
  66. btpip install natsort
  67. pip_list=$($mypip list)
  68. request_v=$(btpip list 2>/dev/null|grep "requests "|awk '{print $2}'|cut -d '.' -f 2)
  69. if [ "$request_v" = "" ] || [ "${request_v}" -gt "28" ];then
  70. $mypip install requests==2.27.1
  71. fi
  72. openssl_v=$(echo "$pip_list"|grep pyOpenSSL)
  73. if [ "$openssl_v" = "" ];then
  74. $mypip install pyOpenSSL
  75. fi
  76. #cffi_v=$(echo "$pip_list"|grep cffi|grep 1.12.)
  77. #if [ "$cffi_v" = "" ];then
  78. # $mypip install cffi==1.12.3
  79. #fi
  80. pymysql=$(echo "$pip_list"|grep pymysql)
  81. if [ "$pymysql" = "" ];then
  82. $mypip install pymysql
  83. fi
  84. pymysql=$(echo "$pip_list"|grep pycryptodome)
  85. if [ "$pymysql" = "" ];then
  86. $mypip install pycryptodome
  87. fi
  88. #psutil=$(echo "$pip_list"|grep psutil|awk '{print $2}'|grep '5.7.')
  89. #if [ "$psutil" = "" ];then
  90. # $mypip install -U psutil
  91. #fi
  92. if [ -d /www/server/panel/class/BTPanel ];then
  93. rm -rf /www/server/panel/class/BTPanel
  94. fi
  95. rm -f /www/server/panel/class/*.so
  96. if [ ! -f /www/server/panel/data/not_workorder.pl ]; then
  97. echo "True" > /www/server/panel/data/not_workorder.pl
  98. fi
  99. if [ ! -f /www/server/panel/data/userInfo.json ]; then
  100. 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
  101. fi
  102. if [ ! -f /www/server/panel/data/panel_nps.pl ]; then
  103. echo "" > /www/server/panel/data/panel_nps.pl
  104. fi
  105. if [ ! -f /www/server/panel/data/btwaf_nps.pl ]; then
  106. echo "" > /www/server/panel/data/btwaf_nps.pl
  107. fi
  108. if [ ! -f /www/server/panel/data/tamper_proof_nps.pl ]; then
  109. echo "" > /www/server/panel/data/tamper_proof_nps.pl
  110. fi
  111. if [ ! -f /www/server/panel/data/total_nps.pl ]; then
  112. echo "" > /www/server/panel/data/total_nps.pl
  113. fi
  114. chattr -i /etc/init.d/bt
  115. chmod +x /etc/init.d/bt
  116. echo "====================================="
  117. rm -f /dev/shm/bt_sql_tips.pl
  118. kill $(ps aux|grep -E "task.pyc|main.py"|grep -v grep|awk '{print $2}')
  119. /etc/init.d/bt restart
  120. echo 'True' > /www/server/panel/data/restart.pl
  121. pkill -9 gunicorn &
  122. echo "已成功升级到[$version]${Ver}";