1
0

upgrade.sh 3.2 KB

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