forked from teddysun/lamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade.sh
121 lines (106 loc) · 3.19 KB
/
upgrade.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#===============================================================================#
# System Required: CentOS/RadHat 5+ / Debian 7+ / Ubuntu 12+ #
# Description: Update LAMP(Linux + Apache + MySQL/MariaDB/Percona + PHP ) #
# Author: Teddysun <i@teddysun.com> #
# Intro: https://lamp.sh #
#===============================================================================#
cur_dir=`pwd`
[[ $EUID -ne 0 ]] && echo "Error: This script must be run as root!" && exit 1
include(){
local include=$1
if [[ -s ${cur_dir}/include/${include}.sh ]];then
. ${cur_dir}/include/${include}.sh
else
echo "Error:${cur_dir}/include/${include}.sh not found, shell can not be executed."
exit 1
fi
}
include config
include public
include upgrade_apache
include upgrade_db
include upgrade_php
include upgrade_phpmyadmin
display_menu(){
echo
echo "#####################################################################"
echo "# Auto Update LAMP(Linux + Apache + MySQL/MariaDB/Percona + PHP ) #"
echo "# Intro: https://lamp.sh #"
echo "# Author: Teddysun <i@teddysun.com> #"
echo "#####################################################################"
echo
rootness
load_config
while :
do
echo -e "\t\033[32m1\033[0m. Upgrade Apache"
echo -e "\t\033[32m2\033[0m. Upgrade MySQL/MariaDB/Percona"
echo -e "\t\033[32m3\033[0m. Upgrade PHP"
echo -e "\t\033[32m4\033[0m. Upgrade phpMyAdmin"
echo -e "\t\033[32m5\033[0m. Exit"
echo
read -p "Please input a number: " Number
if [[ ! $Number =~ ^[1-5]$ ]];then
echo "Input error! Please only input 1,2,3,4,5"
else
case "$Number" in
1)
upgrade_apache 2>&1 | tee /root/upgrade_apache.log
break
;;
2)
upgrade_db 2>&1 | tee /root/upgrade_db.log
break
;;
3)
upgrade_php 2>&1 | tee /root/upgrade_php.log
break
;;
4)
upgrade_phpmyadmin 2>&1 | tee /root/upgrade_phpmyadmin.log
break
;;
5)
exit
;;
esac
fi
done
}
display_usage(){
printf "
Usage: $0 [ apache | db | php | phpmyadmin ]
apache --->Upgrade Apache
db --->Upgrade MySQL/MariaDB/Percona
php --->Upgrade PHP
phpmyadmin --->Upgrade phpMyAdmin
"
}
if [ $# == 0 ];then
display_menu
elif [ $# == 1 ];then
rootness
load_config
case $1 in
apache)
upgrade_apache 2>&1 | tee /root/upgrade_apache.log
;;
db)
upgrade_db 2>&1 | tee /root/upgrade_db.log
;;
php)
upgrade_php 2>&1 | tee /root/upgrade_php.log
;;
phpmyadmin)
upgrade_phpmyadmin 2>&1 | tee /root/upgrade_phpmyadmin.log
;;
*)
display_usage
;;
esac
else
display_usage
fi