upgrade.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.com
  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. # 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/Apache
  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/Apache
  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~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. elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
  76. Upgrade_Apache
  77. fi
  78. ;;
  79. 2)
  80. Upgrade_DB
  81. ;;
  82. 3)
  83. Upgrade_PHP
  84. ;;
  85. 4)
  86. Upgrade_Redis
  87. ;;
  88. 5)
  89. Upgrade_Memcached
  90. ;;
  91. 6)
  92. Upgrade_phpMyAdmin
  93. ;;
  94. q)
  95. exit
  96. ;;
  97. esac
  98. fi
  99. done
  100. }
  101. if [ $# == 0 ]; then
  102. Menu
  103. elif [ $# == 1 ]; then
  104. case $1 in
  105. web)
  106. if [ -e "$nginx_install_dir/sbin/nginx" ]; then
  107. Upgrade_Nginx
  108. elif [ -e "$tengine_install_dir/sbin/nginx" ]; then
  109. Upgrade_Tengine
  110. elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
  111. Upgrade_OpenResty
  112. elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
  113. Upgrade_Apache
  114. fi
  115. ;;
  116. db)
  117. Upgrade_DB
  118. ;;
  119. php)
  120. Upgrade_PHP
  121. ;;
  122. redis)
  123. Upgrade_Redis
  124. ;;
  125. memcached)
  126. Upgrade_Memcached
  127. ;;
  128. phpmyadmin)
  129. Upgrade_phpMyAdmin
  130. ;;
  131. *)
  132. Usage
  133. ;;
  134. esac
  135. else
  136. Usage
  137. fi