upgrade.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 6+ Debian 7+ 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 6+ Debian 7+ and Ubuntu 12+ #
  15. # Upgrade Software versions for OneinStack #
  16. # For more information please visit https://oneinstack.com #
  17. #######################################################################
  18. "
  19. # Check if user is root
  20. [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  21. oneinstack_dir=$(dirname "`readlink -f $0`")
  22. pushd ${oneinstack_dir} > /dev/null
  23. . ./versions.txt
  24. . ./options.conf
  25. . ./include/color.sh
  26. . ./include/check_os.sh
  27. . ./include/check_dir.sh
  28. . ./include/download.sh
  29. . ./include/get_char.sh
  30. . ./include/upgrade_web.sh
  31. . ./include/upgrade_db.sh
  32. . ./include/upgrade_php.sh
  33. . ./include/upgrade_redis.sh
  34. . ./include/upgrade_memcached.sh
  35. . ./include/upgrade_phpmyadmin.sh
  36. . ./include/upgrade_oneinstack.sh
  37. # get the IP information
  38. PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
  39. IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'`
  40. Usage(){
  41. printf "
  42. Usage: $0 [ ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}redis${CEND} | ${CMSG}memcached${CEND} | ${CMSG}phpmyadmin${CEND} | ${CMSG}oneinstack${CEND} ]
  43. ${CMSG}web${CEND} --->Upgrade Nginx/Tengine/OpenResty/Apache
  44. ${CMSG}db${CEND} --->Upgrade MySQL/MariaDB/Percona
  45. ${CMSG}php${CEND} --->Upgrade PHP
  46. ${CMSG}redis${CEND} --->Upgrade Redis
  47. ${CMSG}memcached${CEND} --->Upgrade Memcached
  48. ${CMSG}phpmyadmin${CEND} --->Upgrade phpMyAdmin
  49. ${CMSG}oneinstack${CEND} --->Upgrade OneinStack
  50. "
  51. }
  52. Menu(){
  53. while :; do
  54. printf "
  55. What Are You Doing?
  56. \t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty/Apache
  57. \t${CMSG}2${CEND}. Upgrade MySQL/MariaDB/Percona
  58. \t${CMSG}3${CEND}. Upgrade PHP
  59. \t${CMSG}4${CEND}. Upgrade Redis
  60. \t${CMSG}5${CEND}. Upgrade Memcached
  61. \t${CMSG}6${CEND}. Upgrade phpMyAdmin
  62. \t${CMSG}7${CEND}. Upgrade OneinStack
  63. \t${CMSG}q${CEND}. Exit
  64. "
  65. echo
  66. read -p "Please input the correct option: " Number
  67. if [[ ! $Number =~ ^[1-7,q]$ ]]; then
  68. echo "${CWARNING}input error! Please only input 1~7 and q${CEND}"
  69. else
  70. case "$Number" in
  71. 1)
  72. if [ -e "$nginx_install_dir/sbin/nginx" ]; then
  73. Upgrade_Nginx
  74. elif [ -e "$tengine_install_dir/sbin/nginx" ]; then
  75. Upgrade_Tengine
  76. elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
  77. Upgrade_OpenResty
  78. elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
  79. Upgrade_Apache
  80. fi
  81. ;;
  82. 2)
  83. Upgrade_DB
  84. ;;
  85. 3)
  86. Upgrade_PHP
  87. ;;
  88. 4)
  89. Upgrade_Redis
  90. ;;
  91. 5)
  92. Upgrade_Memcached
  93. ;;
  94. 6)
  95. Upgrade_phpMyAdmin
  96. ;;
  97. 7)
  98. Upgrade_OneinStack
  99. ;;
  100. q)
  101. exit
  102. ;;
  103. esac
  104. fi
  105. done
  106. }
  107. if [ $# == 0 ]; then
  108. Menu
  109. elif [ $# == 1 ]; then
  110. case $1 in
  111. web)
  112. if [ -e "$nginx_install_dir/sbin/nginx" ]; then
  113. Upgrade_Nginx
  114. elif [ -e "$tengine_install_dir/sbin/nginx" ]; then
  115. Upgrade_Tengine
  116. elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
  117. Upgrade_OpenResty
  118. elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
  119. Upgrade_Apache
  120. fi
  121. ;;
  122. db)
  123. Upgrade_DB
  124. ;;
  125. php)
  126. Upgrade_PHP
  127. ;;
  128. redis)
  129. Upgrade_Redis
  130. ;;
  131. memcached)
  132. Upgrade_Memcached
  133. ;;
  134. phpmyadmin)
  135. Upgrade_phpMyAdmin
  136. ;;
  137. oneinstack)
  138. Upgrade_OneinStack
  139. ;;
  140. *)
  141. Usage
  142. ;;
  143. esac
  144. else
  145. Usage
  146. fi