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.

122 lines
3.5 KiB

3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years 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. wget -T 5 -O /tmp/panel.zip $Btapi_Url/install/update/LinuxPanel-${version}.zip
  45. dsize=$(du -b /tmp/panel.zip|awk '{print $1}')
  46. if [ $dsize -lt 10240 ];then
  47. echo "获取更新包失败,请稍后更新或联系宝塔运维"
  48. exit;
  49. fi
  50. unzip -o /tmp/panel.zip -d $setup_path/server/ > /dev/null
  51. rm -f /tmp/panel.zip
  52. cd $setup_path/server/panel/
  53. check_bt=`cat /etc/init.d/bt`
  54. if [ "${check_bt}" = "" ];then
  55. rm -f /etc/init.d/bt
  56. wget -O /etc/init.d/bt $download_Url/install/src/bt7.init -T 20
  57. chmod +x /etc/init.d/bt
  58. fi
  59. rm -f /www/server/panel/*.pyc
  60. rm -f /www/server/panel/class/*.pyc
  61. #pip install flask_sqlalchemy
  62. #pip install itsdangerous==0.24
  63. pip_list=$($mypip list)
  64. request_v=$(echo "$pip_list"|grep requests)
  65. if [ "$request_v" = "" ];then
  66. $mypip install requests
  67. fi
  68. openssl_v=$(echo "$pip_list"|grep pyOpenSSL)
  69. if [ "$openssl_v" = "" ];then
  70. $mypip install pyOpenSSL
  71. fi
  72. #cffi_v=$(echo "$pip_list"|grep cffi|grep 1.12.)
  73. #if [ "$cffi_v" = "" ];then
  74. # $mypip install cffi==1.12.3
  75. #fi
  76. pymysql=$(echo "$pip_list"|grep pymysql)
  77. if [ "$pymysql" = "" ];then
  78. $mypip install pymysql
  79. fi
  80. pymysql=$(echo "$pip_list"|grep pycryptodome)
  81. if [ "$pymysql" = "" ];then
  82. $mypip install pycryptodome
  83. fi
  84. #psutil=$(echo "$pip_list"|grep psutil|awk '{print $2}'|grep '5.7.')
  85. #if [ "$psutil" = "" ];then
  86. # $mypip install -U psutil
  87. #fi
  88. if [ -d /www/server/panel/class/BTPanel ];then
  89. rm -rf /www/server/panel/class/BTPanel
  90. fi
  91. rm -f /www/server/panel/class/*.so
  92. if [ ! -f /www/server/panel/data/not_workorder.pl ]; then
  93. echo "True" > /www/server/panel/data/not_workorder.pl
  94. fi
  95. if [ ! -f /www/server/panel/data/userInfo.json ]; then
  96. 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
  97. fi
  98. chattr -i /etc/init.d/bt
  99. chmod +x /etc/init.d/bt
  100. echo "====================================="
  101. rm -f /dev/shm/bt_sql_tips.pl
  102. kill $(ps aux|grep -E "task.pyc|main.py"|grep -v grep|awk '{print $2}')
  103. /etc/init.d/bt restart
  104. echo 'True' > /www/server/panel/data/restart.pl
  105. pkill -9 gunicorn &
  106. echo "已成功升级到[$version]${Ver}";