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.6 KiB

3 years ago
3 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. public_file=/www/server/panel/install/public.sh
  13. publicFileMd5=$(md5sum ${public_file} 2>/dev/null|awk '{print $1}')
  14. md5check="f6ccaaec227577b87a22bf162004667b"
  15. if [ "${publicFileMd5}" != "${md5check}" ]; then
  16. wget -O Tpublic.sh $Btapi_Url/install/public.sh -T 20;
  17. publicFileMd5=$(md5sum Tpublic.sh 2>/dev/null|awk '{print $1}')
  18. if [ "${publicFileMd5}" == "${md5check}" ]; then
  19. \cp -rpa Tpublic.sh $public_file
  20. fi
  21. rm -f Tpublic.sh
  22. fi
  23. . $public_file
  24. Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
  25. if [ "${Centos8Check}" ];then
  26. if [ ! -f "/usr/bin/python" ] && [ -f "/usr/bin/python3" ] && [ ! -d "/www/server/panel/pyenv" ]; then
  27. ln -sf /usr/bin/python3 /usr/bin/python
  28. fi
  29. fi
  30. mypip="pip"
  31. env_path=/www/server/panel/pyenv/bin/activate
  32. if [ -f $env_path ];then
  33. mypip="/www/server/panel/pyenv/bin/pip"
  34. fi
  35. download_Url=$NODE_URL
  36. setup_path=/www
  37. version=$(curl -Ss --connect-timeout 5 -m 2 $Btapi_Url/api/panel/get_version)
  38. if [ "$version" = '' ];then
  39. version='7.9.3'
  40. fi
  41. armCheck=$(uname -m|grep arm)
  42. if [ "${armCheck}" ];then
  43. version='7.7.0'
  44. fi
  45. wget -T 5 -O /tmp/panel.zip $Btapi_Url/install/update/LinuxPanel-${version}.zip
  46. dsize=$(du -b /tmp/panel.zip|awk '{print $1}')
  47. if [ $dsize -lt 10240 ];then
  48. echo "获取更新包失败,请稍后更新或联系宝塔运维"
  49. exit;
  50. fi
  51. unzip -o /tmp/panel.zip -d $setup_path/server/ > /dev/null
  52. rm -f /tmp/panel.zip
  53. cd $setup_path/server/panel/
  54. check_bt=`cat /etc/init.d/bt`
  55. if [ "${check_bt}" = "" ];then
  56. rm -f /etc/init.d/bt
  57. wget -O /etc/init.d/bt $download_Url/install/src/bt7.init -T 20
  58. chmod +x /etc/init.d/bt
  59. fi
  60. rm -f /www/server/panel/*.pyc
  61. rm -f /www/server/panel/class/*.pyc
  62. #pip install flask_sqlalchemy
  63. #pip install itsdangerous==0.24
  64. pip_list=$($mypip list)
  65. request_v=$(echo "$pip_list"|grep requests)
  66. if [ "$request_v" = "" ];then
  67. $mypip install requests
  68. fi
  69. openssl_v=$(echo "$pip_list"|grep pyOpenSSL)
  70. if [ "$openssl_v" = "" ];then
  71. $mypip install pyOpenSSL
  72. fi
  73. #cffi_v=$(echo "$pip_list"|grep cffi|grep 1.12.)
  74. #if [ "$cffi_v" = "" ];then
  75. # $mypip install cffi==1.12.3
  76. #fi
  77. pymysql=$(echo "$pip_list"|grep pymysql)
  78. if [ "$pymysql" = "" ];then
  79. $mypip install pymysql
  80. fi
  81. pymysql=$(echo "$pip_list"|grep pycryptodome)
  82. if [ "$pymysql" = "" ];then
  83. $mypip install pycryptodome
  84. fi
  85. #psutil=$(echo "$pip_list"|grep psutil|awk '{print $2}'|grep '5.7.')
  86. #if [ "$psutil" = "" ];then
  87. # $mypip install -U psutil
  88. #fi
  89. if [ -d /www/server/panel/class/BTPanel ];then
  90. rm -rf /www/server/panel/class/BTPanel
  91. fi
  92. rm -f /www/server/panel/class/*.so
  93. if [ ! -f /www/server/panel/data/not_workorder.pl ]; then
  94. echo "True" > /www/server/panel/data/not_workorder.pl
  95. fi
  96. if [ ! -f /www/server/panel/data/userInfo.json ]; then
  97. 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
  98. fi
  99. chattr -i /etc/init.d/bt
  100. chmod +x /etc/init.d/bt
  101. echo "====================================="
  102. rm -f /dev/shm/bt_sql_tips.pl
  103. kill $(ps aux|grep -E "task.pyc|main.py"|grep -v grep|awk '{print $2}')
  104. /etc/init.d/bt restart
  105. echo 'True' > /www/server/panel/data/restart.pl
  106. pkill -9 gunicorn &
  107. echo "已成功升级到[$version]${Ver}";