-
Notifications
You must be signed in to change notification settings - Fork 1
/
zpanel_10_1_1.sh
165 lines (144 loc) · 5.28 KB
/
zpanel_10_1_1.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
#!/usr/bin/env bash
# OS VERSION: CentOS 6.4+ Minimal
# ARCH: x32_64
ZPX_VERSION=10.1.1
ZPX_VERSION_ACTUAL="setso --show dbversion"
# Official ZPanel Automated Upgrade Script
# =============================================
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# First we check if the user is 'root' before allowing the upgrade to commence
if [ $UID -ne 0 ]; then
echo "Upgrade failed! To upgrade you must be logged in as 'root', please try again"
exit 1;
fi
# Ensure the upgrade script is launched and can only be launched on CentOs 6.4
BITS=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
if [ -f /etc/centos-release ]; then
OS="CentOs"
VER=$(cat /etc/centos-release | sed 's/^.*release //;s/ (Fin.*$//')
else
OS=$(uname -s)
VER=$(uname -r)
fi
echo "Detected : $OS $VER $BITS"
if [ "$OS" = "CentOs" ] && [ "$VER" = "6.5" ]; then
echo "Ok."
else
echo "Sorry, this upgrade script only supports ZPanel on CentOS 6.4."
exit 1;
fi
#check zpanel version
if [ "$ZPX_VERSION" = "$ZPX_VERSION_ACTUAL" ] ; then
echo "your version of ZPanel already updated"
fi
# Set custom logging methods so we create a log file in the current working directory.
logfile=$$.log
exec > >(tee $logfile)
exec 2>&1
# Check that ZPanel has been detected on the server if not, we'll exit!
if [ ! -d /etc/zpanel ]; then
echo "ZPanel has not been detected on this server, the upgrade script can therefore not continue!"
exit 1;
fi
# Lets check that the user wants to continue first and recommend they have a backup!
echo ""
echo "The ZPanel Upgrade script is now ready to start, we recommend that before"
echo "continuing that you first backup your ZPanel server to enable a restore"
echo "in the event that something goes wrong during the upgrade process!"
echo ""
while true; do
read -e -p "Would you like to continue with the upgrade now (y/n)? " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;
esac
done
# Now we'll ask upgrade specific questions...
echo -e "Please enter the version of which you'd like to upgrade ZPanel to, for example 10-1-1"
read -e -p "Upgrade to version:" -i "10-1-1" upgradeto
echo -e ""
echo -e "Please provide your current MySQL root password (this can found in /etc/zpanel/panel/cnf/db.php)"
read -esp "MySQL root password: " -i "" mysqlpassword
echo -e ""
while true; do
read -e -p "ZPanel will now update, are you sure (y/n)? " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;
esac
done
# We now clone the latest ZPX software from GitHub
echo "Downloading ZPanel, Please wait, this may take several minutes, the installer will continue after this is complete!"
git clone https://github.com/bobsta63/zpanelx.git
cd zpanelx/
git checkout $ZPX_VERSION
mkdir ../zp_install_cache/
git checkout-index -a -f --prefix=../zp_install_cache/
cd ../zp_install_cache/
rm -rf cnf/
# Lets run OS software updates
yum -y update
yum -y upgrade
# Now we make ZPanel application/file specific updates
cp -R . /etc/zpanel/panel/
chmod -R 777 /etc/zpanel/
chmod 644 /etc/zpanel/panel/etc/apps/phpmyadmin/config.inc.php
cc -o /etc/zpanel/panel/bin/zsudo /etc/zpanel/configs/bin/zsudo.c
chown root /etc/zpanel/panel/bin/zsudo
chmod +s /etc/zpanel/panel/bin/zsudo
# Lets execute MySQL data upgrade scripts
cat /etc/zpanel/panel/etc/build/config_packs/centos_6_3/zpanelx-update/$upgradeto/sql/*.sql | mysql -u root -p$mysqlpassword
updatemessage=""
for each in /etc/zpanel/panel/etc/build/config_packs/centos_6_3/zpanelx-update/$upgradeto/shell/*.sh ; do
updatemessage="$updatemessage\n"$(bash $each) ;
done
# We ensure that the daemons are registered for automatic startup and are restarted for changes to take effect
chkconfig httpd on
chkconfig postfix on
chkconfig dovecot on
chkconfig crond on
chkconfig mysqld on
chkconfig named on
chkconfig proftpd on
service httpd restart
service postfix restart
service dovecot restart
service crond restart
service mysqld restart
service named restart
service proftpd restart
service atd restart
php /etc/zpanel/panel/bin/daemon.php
# We'll now remove the temporary install cache.
cd ../
rm -rf zpanelx/ zp_install_cache/
# We now display to the user(s) update SQL/BASH upgrade script messages etc.
echo -e ""
echo -e "###################################################################"
echo -e "# Please read and note down any update errors and messages below: #"
echo -e "# $updatemessage #"
echo -e "# #"
echo -e "###################################################################"
echo -e ""
# We now recommend that the user restarts their server...
while true; do
read -e -p "Restart your server now to complete the upgrade (y/n)? " rsn
case $rsn in
[Yy]* ) break;;
[Nn]* ) exit;
esac
done
shutdown -r now