upgrade.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # http://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  11. clear
  12. printf "
  13. #######################################################################
  14. # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
  15. # upgrade Web,Database,PHP,Redis,phpMyAdmin for OneinStack #
  16. # For more information please visit http://oneinstack.com #
  17. #######################################################################
  18. "
  19. # get pwd
  20. sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
  21. . ./apps.conf
  22. . ./options.conf
  23. . ./include/color.sh
  24. . ./include/check_os.sh
  25. . ./include/check_db.sh
  26. . ./include/download.sh
  27. . ./include/get_char.sh
  28. . ./include/upgrade_web.sh
  29. . ./include/upgrade_db.sh
  30. . ./include/upgrade_php.sh
  31. . ./include/upgrade_redis.sh
  32. . ./include/upgrade_phpmyadmin.sh
  33. # Check if user is root
  34. [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  35. # get the IP information
  36. PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
  37. [ "`./include/get_ipaddr_state.py $PUBLIC_IPADDR`" == '\u4e2d\u56fd' ] && IPADDR_STATE=CN
  38. Usage(){
  39. printf "
  40. Usage: $0 [ ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}redis${CEND} | ${CMSG}phpmyadmin${CEND} ]
  41. ${CMSG}web${CEND} --->Upgrade Nginx/Tengine/OpenResty
  42. ${CMSG}db${CEND} --->Upgrade MySQL/MariaDB/Percona
  43. ${CMSG}php${CEND} --->Upgrade PHP
  44. ${CMSG}redis${CEND} --->Upgrade Redis
  45. ${CMSG}phpmyadmin${CEND} --->Upgrade phpMyAdmin
  46. "
  47. }
  48. Menu(){
  49. while :
  50. do
  51. printf "
  52. What Are You Doing?
  53. \t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty
  54. \t${CMSG}2${CEND}. Upgrade MySQL/MariaDB/Percona
  55. \t${CMSG}3${CEND}. Upgrade PHP
  56. \t${CMSG}4${CEND}. Upgrade Redis
  57. \t${CMSG}5${CEND}. Upgrade phpMyAdmin
  58. \t${CMSG}q${CEND}. Exit
  59. "
  60. echo
  61. read -p "Please input the correct option: " Number
  62. if [[ ! $Number =~ ^[1-5,q]$ ]];then
  63. echo "${CWARNING}input error! Please only input 1,2,3,4,5 and q${CEND}"
  64. else
  65. case "$Number" in
  66. 1)
  67. if [ -e "$nginx_install_dir/sbin/nginx" ];then
  68. Upgrade_Nginx
  69. elif [ -e "$tengine_install_dir/sbin/nginx" ];then
  70. Upgrade_Tengine
  71. elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ];then
  72. Upgrade_OpenResty
  73. fi
  74. ;;
  75. 2)
  76. Upgrade_DB
  77. ;;
  78. 3)
  79. Upgrade_PHP
  80. ;;
  81. 4)
  82. Upgrade_Redis
  83. ;;
  84. 5)
  85. Upgrade_phpMyAdmin
  86. ;;
  87. q)
  88. exit
  89. ;;
  90. esac
  91. fi
  92. done
  93. }
  94. if [ $# == 0 ];then
  95. Menu
  96. elif [ $# == 1 ];then
  97. case $1 in
  98. web)
  99. if [ -e "$nginx_install_dir/sbin/nginx" ];then
  100. Upgrade_Nginx
  101. elif [ -e "$tengine_install_dir/sbin/nginx" ];then
  102. Upgrade_Tengine
  103. elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ];then
  104. Upgrade_OpenResty
  105. fi
  106. ;;
  107. db)
  108. Upgrade_DB
  109. ;;
  110. php)
  111. Upgrade_PHP
  112. ;;
  113. redis)
  114. Upgrade_Redis
  115. ;;
  116. phpmyadmin)
  117. Upgrade_phpMyAdmin
  118. ;;
  119. *)
  120. Usage
  121. ;;
  122. esac
  123. else
  124. Usage
  125. fi