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.

127 lines
3.7 KiB

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='7.9.9'
  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. pip_list=$($mypip list)
  67. request_v=$(btpip list 2>/dev/null|grep "requests "|awk '{print $2}'|cut -d '.' -f 2)
  68. if [ "$request_v" = "" ] || [ "${request_v}" -gt "28" ];then
  69. $mypip install requests==2.27.1
  70. fi
  71. openssl_v=$(echo "$pip_list"|grep pyOpenSSL)
  72. if [ "$openssl_v" = "" ];then
  73. $mypip install pyOpenSSL
  74. fi
  75. #cffi_v=$(echo "$pip_list"|grep cffi|grep 1.12.)
  76. #if [ "$cffi_v" = "" ];then
  77. # $mypip install cffi==1.12.3
  78. #fi
  79. pymysql=$(echo "$pip_list"|grep pymysql)
  80. if [ "$pymysql" = "" ];then
  81. $mypip install pymysql
  82. fi
  83. pymysql=$(echo "$pip_list"|grep pycryptodome)
  84. if [ "$pymysql" = "" ];then
  85. $mypip install pycryptodome
  86. fi
  87. #psutil=$(echo "$pip_list"|grep psutil|awk '{print $2}'|grep '5.7.')
  88. #if [ "$psutil" = "" ];then
  89. # $mypip install -U psutil
  90. #fi
  91. if [ -d /www/server/panel/class/BTPanel ];then
  92. rm -rf /www/server/panel/class/BTPanel
  93. fi
  94. rm -f /www/server/panel/class/*.so
  95. if [ ! -f /www/server/panel/data/not_workorder.pl ]; then
  96. echo "True" > /www/server/panel/data/not_workorder.pl
  97. fi
  98. if [ ! -f /www/server/panel/data/userInfo.json ]; then
  99. 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
  100. fi
  101. chattr -i /etc/init.d/bt
  102. chmod +x /etc/init.d/bt
  103. echo "====================================="
  104. rm -f /dev/shm/bt_sql_tips.pl
  105. kill $(ps aux|grep -E "task.pyc|main.py"|grep -v grep|awk '{print $2}')
  106. /etc/init.d/bt restart
  107. echo 'True' > /www/server/panel/data/restart.pl
  108. pkill -9 gunicorn &
  109. echo "已成功升级到[$version]${Ver}";