upgrade.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # Blog: http://blog.linuxeye.com
  4. # Check if user is root
  5. [ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; }
  6. export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  7. clear
  8. printf "
  9. #######################################################################
  10. # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
  11. # upgrade Web,Database,PHP,Redis,phpMyAdmin for OneinStack #
  12. # For more information please visit http://oneinstack.com #
  13. #######################################################################
  14. "
  15. . ./options.conf
  16. . ./functions/upgrade_web.sh
  17. . ./functions/upgrade_db.sh
  18. . ./functions/upgrade_php.sh
  19. . ./functions/upgrade_redis.sh
  20. . ./functions/upgrade_phpmyadmin.sh
  21. get_char()
  22. {
  23. SAVEDSTTY=`stty -g`
  24. stty -echo
  25. stty cbreak
  26. dd if=/dev/tty bs=1 count=1 2> /dev/null
  27. stty -raw
  28. stty echo
  29. stty $SAVEDSTTY
  30. }
  31. Usage(){
  32. echo
  33. echo -e $"\033[035mUsage:\033[0m \033[032m $0 [ web | db | php | redis | phpmyadmin ]\033[0m"
  34. echo -e "-------------------------------------------------------"
  35. echo -e "\033[032mweb\033[0m --->Upgrade Nginx/Tengine"
  36. echo -e "\033[032mdb\033[0m --->Upgrade MySQL/MariaDB/Percona"
  37. echo -e "\033[032mphp\033[0m --->Upgrade PHP"
  38. echo -e "\033[032mredis\033[0m --->Upgrade Redis"
  39. echo -e "\033[032mphpmyadmin\033[0m --->Upgrade phpMyAdmin"
  40. echo
  41. }
  42. Menu(){
  43. while :
  44. do
  45. echo
  46. echo -e "What Are You Doing?
  47. \t\033[32m1\033[0m. Upgrade Nginx/Tengine
  48. \t\033[32m2\033[0m. Upgrade MySQL/MariaDB/Percona
  49. \t\033[32m3\033[0m. Upgrade PHP
  50. \t\033[32m4\033[0m. Upgrade Redis
  51. \t\033[32m5\033[0m. Upgrade phpMyAdmin
  52. \t\033[32mq\033[0m. Exit"
  53. read -p "Please input the correct option: " Number
  54. if [ "$Number" != '1' -a "$Number" != '2' -a "$Number" != '3' -a "$Number" != '4' -a "$Number" != '5' -a "$Number" != 'q' ];then
  55. echo -e "\033[31minput error! Please only input 1 ~ 5 and q\033[0m"
  56. else
  57. case "$Number" in
  58. 1)
  59. if [ ! -e "$web_install_dir/sbin/dso_tool" ];then
  60. Upgrade_Nginx
  61. elif [ -e "$web_install_dir/sbin/dso_tool" ];then
  62. Upgrade_Tengine
  63. fi
  64. ;;
  65. 2)
  66. Upgrade_DB
  67. ;;
  68. 3)
  69. Upgrade_PHP
  70. ;;
  71. 4)
  72. Upgrade_Redis
  73. ;;
  74. 5)
  75. Upgrade_phpMyAdmin
  76. ;;
  77. q)
  78. exit
  79. ;;
  80. esac
  81. fi
  82. done
  83. }
  84. if [ $# == 0 ];then
  85. Menu
  86. elif [ $# == 1 ];then
  87. case $1 in
  88. web)
  89. if [ ! -e "$web_install_dir/sbin/dso_tool" ];then
  90. Upgrade_Nginx
  91. elif [ -e "$web_install_dir/sbin/dso_tool" ];then
  92. Upgrade_Tengine
  93. fi
  94. ;;
  95. db)
  96. Upgrade_DB
  97. ;;
  98. php)
  99. Upgrade_PHP
  100. ;;
  101. redis)
  102. Upgrade_Redis
  103. ;;
  104. phpmyadmin)
  105. Upgrade_phpMyAdmin
  106. ;;
  107. *)
  108. Usage
  109. ;;
  110. esac
  111. else
  112. Usage
  113. fi