upgrade.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 Nginx/Tengine,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_php.sh
  18. . ./functions/upgrade_redis.sh
  19. . ./functions/upgrade_phpmyadmin.sh
  20. get_char()
  21. {
  22. SAVEDSTTY=`stty -g`
  23. stty -echo
  24. stty cbreak
  25. dd if=/dev/tty bs=1 count=1 2> /dev/null
  26. stty -raw
  27. stty echo
  28. stty $SAVEDSTTY
  29. }
  30. Usage(){
  31. echo
  32. echo -e $"\033[035mUsage:\033[0m \033[032m $0 [ web | php | redis | phpmyadmin ]\033[0m"
  33. echo -e "-------------------------------------------------------"
  34. echo -e "\033[032mweb\033[0m --->Upgrade Nginx/Tengine"
  35. echo -e "\033[032mphp\033[0m --->Upgrade PHP"
  36. echo -e "\033[032mredis\033[0m --->Upgrade Redis"
  37. echo -e "\033[032mphpmyadmin\033[0m --->Upgrade phpMyAdmin"
  38. echo
  39. }
  40. Menu(){
  41. while :
  42. do
  43. echo
  44. echo -e "What Are You Doing?
  45. \t\033[32m1\033[0m. Upgrade Nginx/Tengine
  46. \t\033[32m2\033[0m. Upgrade PHP
  47. \t\033[32m3\033[0m. Upgrade Redis
  48. \t\033[32m4\033[0m. Upgrade phpMyAdmin
  49. \t\033[32mq\033[0m. Exit"
  50. read -p "Please input the correct option: " Number
  51. if [ "$Number" != '1' -a "$Number" != '2' -a "$Number" != '3' -a "$Number" != '4' -a "$Number" != 'q' ];then
  52. echo -e "\033[31minput error! Please only input 1 ~ 4 and q\033[0m"
  53. else
  54. case "$Number" in
  55. 1)
  56. if [ ! -e "$web_install_dir/sbin/dso_tool" ];then
  57. Upgrade_Nginx
  58. elif [ -e "$web_install_dir/sbin/dso_tool" ];then
  59. Upgrade_Tengine
  60. fi
  61. ;;
  62. 2)
  63. Upgrade_PHP
  64. ;;
  65. 3)
  66. Upgrade_Redis
  67. ;;
  68. 4)
  69. Upgrade_phpMyAdmin
  70. ;;
  71. q)
  72. exit
  73. ;;
  74. esac
  75. fi
  76. done
  77. }
  78. if [ $# == 0 ];then
  79. Menu
  80. elif [ $# == 1 ];then
  81. case $1 in
  82. web)
  83. if [ ! -e "$web_install_dir/sbin/dso_tool" ];then
  84. Upgrade_Nginx
  85. elif [ -e "$web_install_dir/sbin/dso_tool" ];then
  86. Upgrade_Tengine
  87. fi
  88. ;;
  89. php)
  90. Upgrade_PHP
  91. ;;
  92. redis)
  93. Upgrade_Redis
  94. ;;
  95. phpmyadmin)
  96. Upgrade_phpMyAdmin
  97. ;;
  98. *)
  99. Usage
  100. ;;
  101. esac
  102. else
  103. Usage
  104. fi