1
0

upgrade.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/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/RedHat 7+ Debian 9+ and Ubuntu 16+ #
  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 out ip country
  38. OUTIP_STATE=$(./include/ois.${ARCH} ip_state)
  39. Show_Help() {
  40. echo
  41. echo "Usage: $0 command ...[version]....
  42. --help, -h Show this help message
  43. --nginx [version] Upgrade Nginx
  44. --tengine [version] Upgrade Tengine
  45. --openresty [version] Upgrade OpenResty
  46. --apache [version] Upgrade Apache
  47. --tomcat [version] Upgrade Tomcat
  48. --db [version] Upgrade MySQL/MariaDB/Percona
  49. --php [version] Upgrade PHP
  50. --redis [version] Upgrade Redis
  51. --memcached [version] Upgrade Memcached
  52. --phpmyadmin [version] Upgrade phpMyAdmin
  53. --oneinstack Upgrade OneinStack latest
  54. --acme.sh Upgrade acme.sh latest
  55. "
  56. }
  57. ARG_NUM=$#
  58. TEMP=`getopt -o h --long help,nginx:,tengine:,openresty:,apache:,tomcat:,db:,php:,redis:,memcached:,phpmyadmin:,oneinstack,acme.sh -- "$@" 2>/dev/null`
  59. [ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
  60. eval set -- "${TEMP}"
  61. while :; do
  62. [ -z "$1" ] && break;
  63. case "$1" in
  64. -h|--help)
  65. Show_Help; exit 0
  66. ;;
  67. --nginx)
  68. nginx_flag=y; NEW_nginx_ver=$2; shift 2
  69. ;;
  70. --tengine)
  71. tengine_flag=y; NEW_tengine_ver=$2; shift 2
  72. ;;
  73. --openresty)
  74. openresty_flag=y; NEW_openresy_ver=$2; shift 2
  75. ;;
  76. --apache)
  77. apache_flag=y; NEW_apache_ver=$2; shift 2
  78. ;;
  79. --tomcat)
  80. tomcat_flag=y; NEW_tomcat_ver=$2; shift 2
  81. ;;
  82. --db)
  83. db_flag=y; NEW_db_ver=$2; shift 2
  84. ;;
  85. --php)
  86. php_flag=y; NEW_php_ver=$2; shift 2
  87. ;;
  88. --redis)
  89. redis_flag=y; NEW_redis_ver=$2; shift 2
  90. ;;
  91. --memcached)
  92. memcached_flag=y; NEW_memcached_ver=$2; shift 2
  93. ;;
  94. --phpmyadmin)
  95. phpmyadmin_flag=y; NEW_phpmyadmin_ver=$2; shift 2
  96. ;;
  97. --oneinstack)
  98. NEW_oneinstack_ver=latest; shift 1
  99. ;;
  100. --acme.sh)
  101. NEW_acme_ver=latest; shift 1
  102. ;;
  103. --)
  104. shift
  105. ;;
  106. *)
  107. echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
  108. ;;
  109. esac
  110. done
  111. Menu() {
  112. while :; do
  113. printf "
  114. What Are You Doing?
  115. \t${CMSG} 1${CEND}. Upgrade Nginx/Tengine/OpenResty
  116. \t${CMSG} 2${CEND}. Upgrade Apache
  117. \t${CMSG} 3${CEND}. Upgrade Tomcat
  118. \t${CMSG} 4${CEND}. Upgrade MySQL/MariaDB/Percona
  119. \t${CMSG} 5${CEND}. Upgrade PHP
  120. \t${CMSG} 6${CEND}. Upgrade Redis
  121. \t${CMSG} 7${CEND}. Upgrade Memcached
  122. \t${CMSG} 8${CEND}. Upgrade phpMyAdmin
  123. \t${CMSG} 9${CEND}. Upgrade OneinStack latest
  124. \t${CMSG}10${CEND}. Upgrade acme.sh latest
  125. \t${CMSG} q${CEND}. Exit
  126. "
  127. echo
  128. read -e -p "Please input the correct option: " Upgrade_flag
  129. if [[ ! "${Upgrade_flag}" =~ ^[1-9,q]$|^10$ ]]; then
  130. echo "${CWARNING}input error! Please only input 1~10 and q${CEND}"
  131. else
  132. case "${Upgrade_flag}" in
  133. 1)
  134. [ -e "${nginx_install_dir}/sbin/nginx" ] && Upgrade_Nginx
  135. [ -e "${tengine_install_dir}/sbin/nginx" ] && Upgrade_Tengine
  136. [ -e "${openresty_install_dir}/nginx/sbin/nginx" ] && Upgrade_OpenResty
  137. ;;
  138. 2)
  139. Upgrade_Apache
  140. ;;
  141. 3)
  142. Upgrade_Tomcat
  143. ;;
  144. 4)
  145. Upgrade_DB
  146. ;;
  147. 5)
  148. Upgrade_PHP
  149. ;;
  150. 6)
  151. Upgrade_Redis
  152. ;;
  153. 7)
  154. Upgrade_Memcached
  155. ;;
  156. 8)
  157. Upgrade_phpMyAdmin
  158. ;;
  159. 9)
  160. Upgrade_OneinStack
  161. ;;
  162. 10)
  163. [ -e ~/.acme.sh/acme.sh ] && { ~/.acme.sh/acme.sh --force --upgrade; ~/.acme.sh/acme.sh --version; }
  164. ;;
  165. q)
  166. exit
  167. ;;
  168. esac
  169. fi
  170. done
  171. }
  172. if [ ${ARG_NUM} == 0 ]; then
  173. Menu
  174. else
  175. [ "${nginx_flag}" == 'y' ] && Upgrade_Nginx
  176. [ "${tengine_flag}" == 'y' ] && Upgrade_Tengine
  177. [ "${openresty_flag}" == 'y' ] && Upgrade_OpenResty
  178. [ "${apache_flag}" == 'y' ] && Upgrade_Apache
  179. [ "${tomcat_flag}" == 'y' ] && Upgrade_Tomcat
  180. [ "${db_flag}" == 'y' ] && Upgrade_DB
  181. [ "${php_flag}" == 'y' ] && Upgrade_PHP
  182. [ "${redis_flag}" == 'y' ] && Upgrade_Redis
  183. [ "${memcached_flag}" == 'y' ] && Upgrade_Memcached
  184. [ "${phpmyadmin_flag}" == 'y' ] && Upgrade_phpMyAdmin
  185. [ "${NEW_oneinstack_ver}" == 'latest' ] && Upgrade_OneinStack
  186. [ "${NEW_acme_ver}" == 'latest' ] && [ -e ~/.acme.sh/acme.sh ] && { ~/.acme.sh/acme.sh --force --upgrade; ~/.acme.sh/acme.sh --version; }
  187. fi