upgrade.sh 3.2 KB

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