-
Notifications
You must be signed in to change notification settings - Fork 763
/
upgrade.sh
executable file
·190 lines (183 loc) · 5.37 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# BLOG: https://linuxeye.com
#
# Notes: LNMP for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
#
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
clear
printf "
#######################################################################
# LNMP for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+ #
# Upgrade Software versions #
#######################################################################
"
# Check if user is root
[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
current_dir=$(dirname "`readlink -f $0`")
pushd ${current_dir} > /dev/null
. ./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_lnmp.sh
# get the out ip country
OUTIP_STATE=$(./include/ois.${ARCH} ip_state)
Show_Help() {
echo
echo "Usage: $0 command ...[version]....
--help, -h Show this help message
--nginx [version] Upgrade Nginx
--tengine [version] Upgrade Tengine
--openresty [version] Upgrade OpenResty
--apache [version] Upgrade Apache
--tomcat [version] Upgrade Tomcat
--db [version] Upgrade MySQL/MariaDB/Percona
--php [version] Upgrade PHP
--redis [version] Upgrade Redis
--memcached [version] Upgrade Memcached
--phpmyadmin [version] Upgrade phpMyAdmin
--oneinstack Upgrade scripts latest
--acme.sh Upgrade acme.sh latest
"
}
ARG_NUM=$#
TEMP=`getopt -o h --long help,nginx:,tengine:,openresty:,apache:,tomcat:,db:,php:,redis:,memcached:,phpmyadmin:,oneinstack,acme.sh -- "$@" 2>/dev/null`
[ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
eval set -- "${TEMP}"
while :; do
[ -z "$1" ] && break;
case "$1" in
-h|--help)
Show_Help; exit 0
;;
--nginx)
nginx_flag=y; NEW_nginx_ver=$2; shift 2
;;
--tengine)
tengine_flag=y; NEW_tengine_ver=$2; shift 2
;;
--openresty)
openresty_flag=y; NEW_openresy_ver=$2; shift 2
;;
--apache)
apache_flag=y; NEW_apache_ver=$2; shift 2
;;
--tomcat)
tomcat_flag=y; NEW_tomcat_ver=$2; shift 2
;;
--db)
db_flag=y; NEW_db_ver=$2; shift 2
;;
--php)
php_flag=y; NEW_php_ver=$2; shift 2
;;
--redis)
redis_flag=y; NEW_redis_ver=$2; shift 2
;;
--memcached)
memcached_flag=y; NEW_memcached_ver=$2; shift 2
;;
--phpmyadmin)
phpmyadmin_flag=y; NEW_phpmyadmin_ver=$2; shift 2
;;
--oneinstack)
NEW_LNMP_ver=latest; shift 1
;;
--acme.sh)
NEW_acme_ver=latest; shift 1
;;
--)
shift
;;
*)
echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
;;
esac
done
Menu() {
while :; do
printf "
What Are You Doing?
\t${CMSG} 1${CEND}. Upgrade Nginx/Tengine/OpenResty
\t${CMSG} 2${CEND}. Upgrade Apache
\t${CMSG} 3${CEND}. Upgrade Tomcat
\t${CMSG} 4${CEND}. Upgrade MySQL/MariaDB/Percona
\t${CMSG} 5${CEND}. Upgrade PHP
\t${CMSG} 6${CEND}. Upgrade Redis
\t${CMSG} 7${CEND}. Upgrade Memcached
\t${CMSG} 8${CEND}. Upgrade phpMyAdmin
\t${CMSG} 9${CEND}. Upgrade scripts latest
\t${CMSG}10${CEND}. Upgrade acme.sh latest
\t${CMSG} q${CEND}. Exit
"
echo
read -e -p "Please input the correct option: " Upgrade_flag
if [[ ! "${Upgrade_flag}" =~ ^[1-9,q]$|^10$ ]]; then
echo "${CWARNING}input error! Please only input 1~10 and q${CEND}"
else
case "${Upgrade_flag}" in
1)
[ -e "${nginx_install_dir}/sbin/nginx" ] && Upgrade_Nginx
[ -e "${tengine_install_dir}/sbin/nginx" ] && Upgrade_Tengine
[ -e "${openresty_install_dir}/nginx/sbin/nginx" ] && Upgrade_OpenResty
;;
2)
Upgrade_Apache
;;
3)
Upgrade_Tomcat
;;
4)
Upgrade_DB
;;
5)
Upgrade_PHP
;;
6)
Upgrade_Redis
;;
7)
Upgrade_Memcached
;;
8)
Upgrade_phpMyAdmin
;;
9)
Upgrade_LNMP
;;
10)
[ -e ~/.acme.sh/acme.sh ] && { ~/.acme.sh/acme.sh --force --upgrade; ~/.acme.sh/acme.sh --version; }
;;
q)
exit
;;
esac
fi
done
}
if [ ${ARG_NUM} == 0 ]; then
Menu
else
[ "${nginx_flag}" == 'y' ] && Upgrade_Nginx
[ "${tengine_flag}" == 'y' ] && Upgrade_Tengine
[ "${openresty_flag}" == 'y' ] && Upgrade_OpenResty
[ "${apache_flag}" == 'y' ] && Upgrade_Apache
[ "${tomcat_flag}" == 'y' ] && Upgrade_Tomcat
[ "${db_flag}" == 'y' ] && Upgrade_DB
[ "${php_flag}" == 'y' ] && Upgrade_PHP
[ "${redis_flag}" == 'y' ] && Upgrade_Redis
[ "${memcached_flag}" == 'y' ] && Upgrade_Memcached
[ "${phpmyadmin_flag}" == 'y' ] && Upgrade_phpMyAdmin
[ "${NEW_LNMP_ver}" == 'latest' ] && Upgrade_LNMP
[ "${NEW_acme_ver}" == 'latest' ] && [ -e ~/.acme.sh/acme.sh ] && { ~/.acme.sh/acme.sh --force --upgrade; ~/.acme.sh/acme.sh --version; }
fi