forked from Ubuntu-ve/lnmp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
upgrade.sh
executable file
·154 lines (146 loc) · 3.88 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# BLOG: https://blog.linuxeye.com
#
# Notes: OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+
#
# Project home page:
# https://oneinstack.com
# https://github.com/lj2007331/oneinstack
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
clear
printf "
#######################################################################
# OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+ #
# Upgrade Software versions for OneinStack #
# For more information please visit https://oneinstack.com #
#######################################################################
"
# get pwd
sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
. ./versions.txt
. ./options.conf
. ./include/color.sh
. ./include/check_os.sh
. ./include/check_dir.sh
. ./include/download.sh
. ./include/get_char.sh
. ./include/upgrade_web.sh
. ./include/upgrade_db.sh
. ./include/upgrade_php.sh
. ./include/upgrade_redis.sh
. ./include/upgrade_memcached.sh
. ./include/upgrade_phpmyadmin.sh
. ./include/upgrade_oneinstack.sh
# Check if user is root
[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
# get the IP information
PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'`
Usage(){
printf "
Usage: $0 [ ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}redis${CEND} | ${CMSG}memcached${CEND} | ${CMSG}phpmyadmin${CEND} | ${CMSG}oneinstack${CEND} ]
${CMSG}web${CEND} --->Upgrade Nginx/Tengine/OpenResty/Apache
${CMSG}db${CEND} --->Upgrade MySQL/MariaDB/Percona
${CMSG}php${CEND} --->Upgrade PHP
${CMSG}redis${CEND} --->Upgrade Redis
${CMSG}memcached${CEND} --->Upgrade Memcached
${CMSG}phpmyadmin${CEND} --->Upgrade phpMyAdmin
${CMSG}oneinstack${CEND} --->Upgrade OneinStack
"
}
Menu(){
while :; do
printf "
What Are You Doing?
\t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty/Apache
\t${CMSG}2${CEND}. Upgrade MySQL/MariaDB/Percona
\t${CMSG}3${CEND}. Upgrade PHP
\t${CMSG}4${CEND}. Upgrade Redis
\t${CMSG}5${CEND}. Upgrade Memcached
\t${CMSG}6${CEND}. Upgrade phpMyAdmin
\t${CMSG}7${CEND}. Upgrade OneinStack
\t${CMSG}q${CEND}. Exit
"
echo
read -p "Please input the correct option: " Number
if [[ ! $Number =~ ^[1-7,q]$ ]]; then
echo "${CWARNING}input error! Please only input 1~7 and q${CEND}"
else
case "$Number" in
1)
if [ -e "$nginx_install_dir/sbin/nginx" ]; then
Upgrade_Nginx
elif [ -e "$tengine_install_dir/sbin/nginx" ]; then
Upgrade_Tengine
elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
Upgrade_OpenResty
elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
Upgrade_Apache
fi
;;
2)
Upgrade_DB
;;
3)
Upgrade_PHP
;;
4)
Upgrade_Redis
;;
5)
Upgrade_Memcached
;;
6)
Upgrade_phpMyAdmin
;;
7)
Upgrade_OneinStack
;;
q)
exit
;;
esac
fi
done
}
if [ $# == 0 ]; then
Menu
elif [ $# == 1 ]; then
case $1 in
web)
if [ -e "$nginx_install_dir/sbin/nginx" ]; then
Upgrade_Nginx
elif [ -e "$tengine_install_dir/sbin/nginx" ]; then
Upgrade_Tengine
elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
Upgrade_OpenResty
elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
Upgrade_Apache
fi
;;
db)
Upgrade_DB
;;
php)
Upgrade_PHP
;;
redis)
Upgrade_Redis
;;
memcached)
Upgrade_Memcached
;;
phpmyadmin)
Upgrade_phpMyAdmin
;;
oneinstack)
Upgrade_OneinStack
;;
*)
Usage
;;
esac
else
Usage
fi