upgrade.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. # https://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 https://oneinstack.com #
  17. #######################################################################
  18. "
  19. # get pwd
  20. sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
  21. . ./versions.txt
  22. . ./options.conf
  23. . ./include/color.sh
  24. . ./include/check_os.sh
  25. . ./include/check_dir.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_memcached.sh
  33. . ./include/upgrade_phpmyadmin.sh
  34. # Check if user is root
  35. [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  36. # get the IP information
  37. PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
  38. IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'`
  39. Usage(){
  40. printf "
  41. Usage: $0 [ ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}redis${CEND} | ${CMSG}memcached${CEND} | ${CMSG}phpmyadmin${CEND} ]
  42. ${CMSG}web${CEND} --->Upgrade Nginx/Tengine/OpenResty
  43. ${CMSG}db${CEND} --->Upgrade MySQL/MariaDB/Percona
  44. ${CMSG}php${CEND} --->Upgrade PHP
  45. ${CMSG}redis${CEND} --->Upgrade Redis
  46. ${CMSG}memcached${CEND} --->Upgrade Memcached
  47. ${CMSG}phpmyadmin${CEND} --->Upgrade phpMyAdmin
  48. "
  49. }
  50. Menu(){
  51. while :; do
  52. printf "
  53. What Are You Doing?
  54. \t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty
  55. \t${CMSG}2${CEND}. Upgrade MySQL/MariaDB/Percona
  56. \t${CMSG}3${CEND}. Upgrade PHP
  57. \t${CMSG}4${CEND}. Upgrade Redis
  58. \t${CMSG}5${CEND}. Upgrade Memcached
  59. \t${CMSG}6${CEND}. Upgrade phpMyAdmin
  60. \t${CMSG}q${CEND}. Exit
  61. "
  62. echo
  63. read -p "Please input the correct option: " Number
  64. if [[ ! $Number =~ ^[1-6,q]$ ]]; then
  65. echo "${CWARNING}input error! Please only input 1,2,3,4,5,6 and q${CEND}"
  66. else
  67. case "$Number" in
  68. 1)
  69. if [ -e "$nginx_install_dir/sbin/nginx" ]; then
  70. Upgrade_Nginx
  71. elif [ -e "$tengine_install_dir/sbin/nginx" ]; then
  72. Upgrade_Tengine
  73. elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
  74. Upgrade_OpenResty
  75. fi
  76. ;;
  77. 2)
  78. Upgrade_DB
  79. ;;
  80. 3)
  81. Upgrade_PHP
  82. ;;
  83. 4)
  84. Upgrade_Redis
  85. ;;
  86. 5)
  87. Upgrade_Memcached
  88. ;;
  89. 6)
  90. Upgrade_phpMyAdmin
  91. ;;
  92. q)
  93. exit
  94. ;;
  95. esac
  96. fi
  97. done
  98. }
  99. if [ $# == 0 ]; then
  100. Menu
  101. elif [ $# == 1 ]; then
  102. case $1 in
  103. web)
  104. if [ -e "$nginx_install_dir/sbin/nginx" ]; then
  105. Upgrade_Nginx
  106. elif [ -e "$tengine_install_dir/sbin/nginx" ]; then
  107. Upgrade_Tengine
  108. elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
  109. Upgrade_OpenResty
  110. fi
  111. ;;
  112. db)
  113. Upgrade_DB
  114. ;;
  115. php)
  116. Upgrade_PHP
  117. ;;
  118. redis)
  119. Upgrade_Redis
  120. ;;
  121. memcached)
  122. Upgrade_Memcached
  123. ;;
  124. phpmyadmin)
  125. Upgrade_phpMyAdmin
  126. ;;
  127. *)
  128. Usage
  129. ;;
  130. esac
  131. else
  132. Usage
  133. fi