upgrade.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/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} | ${CMSG}acme.sh${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. ${CMSG}acme.sh${CEND} --->Upgrade acme.sh
  51. "
  52. }
  53. Menu(){
  54. while :; do
  55. printf "
  56. What Are You Doing?
  57. \t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty/Apache
  58. \t${CMSG}2${CEND}. Upgrade MySQL/MariaDB/Percona
  59. \t${CMSG}3${CEND}. Upgrade PHP
  60. \t${CMSG}4${CEND}. Upgrade Redis
  61. \t${CMSG}5${CEND}. Upgrade Memcached
  62. \t${CMSG}6${CEND}. Upgrade phpMyAdmin
  63. \t${CMSG}7${CEND}. Upgrade OneinStack
  64. \t${CMSG}8${CEND}. Upgrade acme.sh
  65. \t${CMSG}q${CEND}. Exit
  66. "
  67. echo
  68. read -p "Please input the correct option: " Upgrade_flag
  69. if [[ ! ${Upgrade_flag} =~ ^[1-8,q]$ ]]; then
  70. echo "${CWARNING}input error! Please only input 1~8 and q${CEND}"
  71. else
  72. case "${Upgrade_flag}" in
  73. 1)
  74. if [ -e "$nginx_install_dir/sbin/nginx" ]; then
  75. Upgrade_Nginx
  76. elif [ -e "$tengine_install_dir/sbin/nginx" ]; then
  77. Upgrade_Tengine
  78. elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
  79. Upgrade_OpenResty
  80. elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
  81. Upgrade_Apache
  82. fi
  83. ;;
  84. 2)
  85. Upgrade_DB
  86. ;;
  87. 3)
  88. Upgrade_PHP
  89. ;;
  90. 4)
  91. Upgrade_Redis
  92. ;;
  93. 5)
  94. Upgrade_Memcached
  95. ;;
  96. 6)
  97. Upgrade_phpMyAdmin
  98. ;;
  99. 7)
  100. Upgrade_OneinStack
  101. ;;
  102. 8)
  103. [ -e ~/.acme.sh/acme.sh ] && { ~/.acme.sh/acme.sh --upgrade; ~/.acme.sh/acme.sh --version; }
  104. ;;
  105. q)
  106. exit
  107. ;;
  108. esac
  109. fi
  110. done
  111. }
  112. if [ $# == 0 ]; then
  113. Menu
  114. elif [ $# == 1 ]; then
  115. case $1 in
  116. web)
  117. if [ -e "$nginx_install_dir/sbin/nginx" ]; then
  118. Upgrade_Nginx
  119. elif [ -e "$tengine_install_dir/sbin/nginx" ]; then
  120. Upgrade_Tengine
  121. elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
  122. Upgrade_OpenResty
  123. elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
  124. Upgrade_Apache
  125. fi
  126. ;;
  127. db)
  128. Upgrade_DB
  129. ;;
  130. php)
  131. Upgrade_PHP
  132. ;;
  133. redis)
  134. Upgrade_Redis
  135. ;;
  136. memcached)
  137. Upgrade_Memcached
  138. ;;
  139. phpmyadmin)
  140. Upgrade_phpMyAdmin
  141. ;;
  142. oneinstack)
  143. Upgrade_OneinStack
  144. ;;
  145. acme.sh)
  146. [ -e ~/.acme.sh/acme.sh ] && { ~/.acme.sh/acme.sh --upgrade; ~/.acme.sh/acme.sh --version; }
  147. ;;
  148. *)
  149. Usage
  150. ;;
  151. esac
  152. else
  153. Usage
  154. fi