1+ #! /bin/bash
2+
3+ # Hestia Control Panel - Upgrade Control Script
4+
5+ # ####################################################################
6+ # ###### Functions & Initialization #######
7+ # ####################################################################
8+
9+ function upgrade_welcome_message() {
10+ echo
11+ echo ' _ _ _ _ ____ ____ '
12+ echo ' | | | | ___ ___| |_(_) __ _ / ___| _ \ '
13+ echo ' | |_| |/ _ \/ __| __| |/ _` | | | |_) | '
14+ echo ' | _ | __/\__ \ |_| | (_| | |___| __/ '
15+ echo ' |_| |_|\___||___/\__|_|\__,_|\____|_| '
16+ echo " "
17+ echo " Hestia Control Panel Upgrade Script"
18+ echo " Version: $new_version "
19+ echo " ==================================================="
20+ echo " "
21+ echo " Please note that some configuration and template"
22+ echo " files may be replaced during the upgrade process."
23+ echo " "
24+ echo " Backups of these files will be available under:"
25+ echo " $HESTIA_BACKUP /"
26+ echo " "
27+ echo " This process may take a few minutes, please wait..."
28+ echo " "
29+ }
30+
31+ function upgrade_complete_message() {
32+ # Add notification to panel
33+ $HESTIA /bin/v-add-user-notification admin ' Upgrade complete' ' Your server has been updated to Hestia Control Panel version ' $new_version ' .<br>Please report any bugs on GitHub at<br><a href="https://github.com/hestiacp/hestiacp/Issues" target="_new">https://github.com/hestiacp/hestiacp/Issues</a><br><br>Have a great day!'
34+
35+ # Echo message to console output
36+ echo " "
37+ echo " Upgrade complete! Please report any bugs or issues to"
38+ echo " https://github.com/hestiacp/hestiacp/issues"
39+ echo " "
40+ echo " We hope that you enjoy this release of Hestia Control Panel,"
41+ echo " enjoy your day!"
42+ echo " "
43+ echo " Sincerely,"
44+ echo " The Hestia Control Panel development team"
45+ echo " "
46+ echo " www.hestiacp.com"
47+ echo " Made with love & pride by the open-source community around the world."
48+ echo " "
49+ echo " "
50+ }
51+
52+ function upgrade_init_backup() {
53+ # Ensure that backup directories are created
54+ mkdir -p $HESTIA_BACKUP /conf/
55+ mkdir -p $HESTIA_BACKUP /packages/
56+ mkdir -p $HESTIA_BACKUP /templates/
57+ }
58+
59+ function upgrade_start_routine() {
60+
61+ # ####################################################################
62+ # ###### Start upgrade for pre-release builds #######
63+ # ####################################################################
64+
65+ if [ $VERSION = " 0.9.8-25" ] || [ $VERSION = " 0.9.8-26" ] || [ $VERSION = " 0.9.8-27" ] || [ $VERSION = " 0.9.8-28" ] || [ $VERSION = " 0.9.8-29" ] || [ $VERSION = " 0.10.0" ] || [ $VERSION = " 1.00.0-190618" ] || [ $VERSION = " 1.00.0-190621" ]; then
66+ source $HESTIA_INSTALL_DIR /upgrade/versions/previous/0.9.8-29.sh
67+ source $HESTIA_INSTALL_DIR /upgrade/versions/previous/1.00.0-190618.sh
68+ source $HESTIA_INSTALL_DIR /upgrade/versions/previous/1.0.1.sh
69+ VERSION=" 1.0.1"
70+ fi
71+
72+ # ####################################################################
73+ # ###### Start standard upgrade process #######
74+ # ####################################################################
75+
76+ # Upgrade to Version 1.0.2
77+ if [ $VERSION = " 1.0.1" ]; then
78+ source $HESTIA_INSTALL_DIR /upgrade/versions/previous/1.0.2.sh
79+ VERSION=" 1.0.2"
80+ fi
81+
82+ # Upgrade to Version 1.0.3
83+ if [ $VERSION = " 1.0.2" ]; then
84+ source $HESTIA_INSTALL_DIR /upgrade/versions/latest.sh
85+ VERSION=" $new_version "
86+ fi
87+
88+ # Ensure that latest upgrade commands are processed if version is the same
89+ if [ $VERSION = " $new_version " ]; then
90+ echo " (!) The latest version of Hestia Control Panel ($new_version ) is already installed."
91+ echo " Verifying configuration..."
92+ echo " "
93+ source $HESTIA_INSTALL_DIR /upgrade/versions/latest.sh
94+ VERSION=" $new_version "
95+ fi
96+
97+ # ####################################################################
98+ # ###### End upgrade process #######
99+ # ####################################################################
100+ }
101+
102+ function upgrade_phpmyadmin() {
103+ # Define version check function
104+ function version_ge(){ test " $( printf ' %s\n' " $@ " | sort -V | head -n 1) " ! = " $1 " -o ! -z " $1 " -a " $1 " = " $2 " ; }
105+
106+ pma_release_file=$( ls /usr/share/phpmyadmin/RELEASE-DATE-* 2> /dev/null | tail -n 1)
107+ if version_ge " ${pma_release_file##* -} " " $pma_v " ; then
108+ echo " (*) phpMyAdmin $pma_v or newer is already installed: ${pma_release_file##* -} , skipping update..."
109+ else
110+ # Display upgrade information
111+ echo " (*) Upgrade phpMyAdmin to v$pma_v ..."
112+ [ -d /usr/share/phpmyadmin ] || mkdir -p /usr/share/phpmyadmin
113+
114+ # Download latest phpMyAdmin release
115+ wget --quiet https://files.phpmyadmin.net/phpMyAdmin/$pma_v /phpMyAdmin-$pma_v -all-languages.tar.gz
116+
117+ # Unpack files
118+ tar xzf phpMyAdmin-$pma_v -all-languages.tar.gz
119+
120+ # Delete file to prevent error
121+ rm -fr /usr/share/phpmyadmin/doc/html
122+
123+ # Overwrite old files
124+ cp -rf phpMyAdmin-$pma_v -all-languages/* /usr/share/phpmyadmin
125+
126+ # Set config and log directory
127+ sed -i " s|define('CONFIG_DIR', '');|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
128+ sed -i " s|define('TEMP_DIR', './tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
129+
130+ # Create temporary folder and change permissions
131+ if [ ! -d /usr/share/phpmyadmin/tmp ]; then
132+ mkdir /usr/share/phpmyadmin/tmp
133+ chmod 777 /usr/share/phpmyadmin/tmp
134+ fi
135+
136+ # Clean up source files
137+ rm -fr phpMyAdmin-$pma_v -all-languages
138+ rm -f phpMyAdmin-$pma_v -all-languages.tar.gz
139+ fi
140+ }
141+
142+ function upgrade_set_version() {
143+ # Set new version number in hestia.conf
144+ sed -i " /VERSION/d" $HESTIA /conf/hestia.conf
145+ echo " VERSION='$new_version '" >> $HESTIA /conf/hestia.conf
146+ }
147+
148+ function upgrade_rebuild_users() {
149+ for user in ` ls /usr/local/hestia/data/users/` ; do
150+ echo " (*) Rebuilding domains and account for user: $user ..."
151+ if [ ! -z $WEB_SYSTEM ]; then
152+ $BIN /v-rebuild-web-domains $user > /dev/null 2>&1
153+ fi
154+ if [ ! -z $DNS_SYSTEM ]; then
155+ $BIN /v-rebuild-dns-domains $user > /dev/null 2>&1
156+ fi
157+ if [ ! -z $MAIL_SYSTEM ]; then
158+ $BIN /v-rebuild-mail-domains $user > /dev/null 2>&1
159+ fi
160+ done
161+ }
162+
163+ function upgrade_restart_services() {
164+ echo " (*) Restarting services..."
165+ if [ ! -z $MAIL_SYSTEM ]; then
166+ $BIN /v-restart-mail $restart
167+ fi
168+ if [ ! -z $IMAP_SYSTEM ]; then
169+ $BIN /v-restart-service $IMAP_SYSTEM $restart
170+ fi
171+ if [ ! -z $WEB_SYSTEM ]; then
172+ $BIN /v-restart-web $restart
173+ $BIN /v-restart-proxy $restart
174+ fi
175+ if [ ! -z $DNS_SYSTEM ]; then
176+ $BIN /v-restart-dns $restart
177+ fi
178+ for v in ` ls /etc/php/` ; do
179+ if [ -e /etc/php/$v /fpm ]; then
180+ $BIN /v-restart-service php$v -fpm $restart
181+ fi
182+ done
183+ if [ ! -z $FTP_SYSTEM ]; then
184+ $BIN /v-restart-ftp $restart
185+ fi
186+
187+ # Restart SSH daemon and Hestia Control Panel service
188+ $BIN /v-restart-service ssh $restart
189+ $BIN /v-restart-service hestia $restart
190+ }
0 commit comments