upgrade.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. . ./options.conf
  20. . ./include/color.sh
  21. . ./include/check_os.sh
  22. . ./include/check_db.sh
  23. . ./include/download.sh
  24. . ./include/get_char.sh
  25. . ./include/upgrade_web.sh
  26. . ./include/upgrade_db.sh
  27. . ./include/upgrade_php.sh
  28. . ./include/upgrade_redis.sh
  29. . ./include/upgrade_phpmyadmin.sh
  30. # Check if user is root
  31. [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  32. # get the IP information
  33. PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
  34. [ "`./include/get_ipaddr_state.py $PUBLIC_IPADDR`" == '\u4e2d\u56fd' ] && IPADDR_STATE=CN
  35. Usage(){
  36. printf "
  37. Usage: $0 [ ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}redis${CEND} | ${CMSG}phpmyadmin${CEND} ]
  38. ${CMSG}web${CEND} --->Upgrade Nginx/Tengine
  39. ${CMSG}db${CEND} --->Upgrade MySQL/MariaDB/Percona
  40. ${CMSG}php${CEND} --->Upgrade PHP
  41. ${CMSG}redis${CEND} --->Upgrade Redis
  42. ${CMSG}phpmyadmin${CEND} --->Upgrade phpMyAdmin
  43. "
  44. }
  45. Menu(){
  46. while :
  47. do
  48. printf "
  49. What Are You Doing?
  50. \t${CMSG}1${CEND}. Upgrade Nginx/Tengine
  51. \t${CMSG}2${CEND}. Upgrade MySQL/MariaDB/Percona
  52. \t${CMSG}3${CEND}. Upgrade PHP
  53. \t${CMSG}4${CEND}. Upgrade Redis
  54. \t${CMSG}5${CEND}. Upgrade phpMyAdmin
  55. \t${CMSG}q${CEND}. Exit
  56. "
  57. echo
  58. read -p "Please input the correct option: " Number
  59. if [ "$Number" != '1' -a "$Number" != '2' -a "$Number" != '3' -a "$Number" != '4' -a "$Number" != '5' -a "$Number" != 'q' ];then
  60. echo "${CWARNING}input error! Please only input 1 ~ 5 and q${CEND}"
  61. else
  62. case "$Number" in
  63. 1)
  64. if [ -e "$nginx_install_dir/sbin/nginx" ];then
  65. Upgrade_Nginx
  66. elif [ -e "$tengine_install_dir/sbin/nginx" ];then
  67. Upgrade_Tengine
  68. fi
  69. ;;
  70. 2)
  71. Upgrade_DB
  72. ;;
  73. 3)
  74. Upgrade_PHP
  75. ;;
  76. 4)
  77. Upgrade_Redis
  78. ;;
  79. 5)
  80. Upgrade_phpMyAdmin
  81. ;;
  82. q)
  83. exit
  84. ;;
  85. esac
  86. fi
  87. done
  88. }
  89. if [ $# == 0 ];then
  90. Menu
  91. elif [ $# == 1 ];then
  92. case $1 in
  93. web)
  94. if [ -e "$nginx_install_dir/sbin/nginx" ];then
  95. Upgrade_Nginx
  96. elif [ -e "$tengine_install_dir/sbin/nginx" ];then
  97. Upgrade_Tengine
  98. fi
  99. ;;
  100. db)
  101. Upgrade_DB
  102. ;;
  103. php)
  104. Upgrade_PHP
  105. ;;
  106. redis)
  107. Upgrade_Redis
  108. ;;
  109. phpmyadmin)
  110. Upgrade_phpMyAdmin
  111. ;;
  112. *)
  113. Usage
  114. ;;
  115. esac
  116. else
  117. Usage
  118. fi