1
0

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