Skip to content

Commit 5a6ee55

Browse files
Add add_upgrade_message instead old method (hestiacp#2130)
* Add add_upgrade_message instead old method + Improved backup old config files in /etc/ * Update upgrade.sh Enable intepretation of backslash escapes to allow for example new lines within the string. Also add two new lines while adding a new message to prevent having one text block for mutliple notes/issues. * Update 1.4.14.sh * Update version number. Co-authored-by: Raphael Schneeberger <rs@scit.ch>
1 parent 93a665b commit 5a6ee55

File tree

4 files changed

+79
-36
lines changed

4 files changed

+79
-36
lines changed

func/upgrade.sh

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ source $HESTIA/func/syshealth.sh
99
####### Functions & Initialization #######
1010
#####################################################################
1111

12+
add_upgrade_message (){
13+
if [ -f "$HESTIA_BACKUP/message.log" ]; then
14+
echo -e $1 >> $HESTIA_BACKUP/message.log
15+
echo -e "\n\n" >> $HESTIA_BACKUP/message.log
16+
else
17+
echo -e $1 > $HESTIA_BACKUP/message.log
18+
fi
19+
}
20+
1221
is_debug_build() {
1322
if [[ "$new_version" =~ "alpha" ]] || [[ "$new_version" =~ "beta" ]]; then
1423
DEBUG_MODE="true"
@@ -193,11 +202,11 @@ upgrade_send_notification_to_email () {
193202
echo "" >> $message_tmp_file
194203

195204
# Check for additional upgrade notes from update scripts.
196-
if [[ -z "$UPGRADE_MESSAGE" ]]; then
205+
if [[ -f "$HESTIA_BACKUP/message.log" ]]; then
197206
echo "===================================================" >> $message_tmp_file
198207
echo "The upgrade script has generated additional notifications, which must be heeded urgently:" >> $message_tmp_file
199208
echo "" >> $message_tmp_file
200-
echo -e $UPGRADE_MESSAGE >> $message_tmp_file
209+
cat $HESTIA_BACKUP/message.log >> $message_tmp_file
201210
echo "" >> $message_tmp_file
202211
echo "===================================================" >> $message_tmp_file
203212
echo "" >> $message_tmp_file
@@ -307,6 +316,15 @@ upgrade_init_backup() {
307316
if [ -e "/etc/ssh/sshd_config" ]; then
308317
mkdir -p $HESTIA_BACKUP/conf/ssh/
309318
fi
319+
if [ -d "/etc/roundcube/" ]; then
320+
mkdir -p $HESTIA_BACKUP/conf/roundcube/
321+
fi
322+
if [ -d "/etc/rainloop/" ]; then
323+
mkdir -p $HESTIA_BACKUP/conf/rainloop/
324+
fi
325+
if [ -d "/etc/phpmyadmin/" ]; then
326+
mkdir -p $HESTIA_BACKUP/conf/phpmyadmin/
327+
fi
310328
}
311329

312330
upgrade_init_logging() {
@@ -355,57 +373,47 @@ upgrade_start_backup() {
355373
if [ "$DEBUG_MODE" = "true" ]; then
356374
echo " ---- $WEB_SYSTEM"
357375
fi
358-
cp -f /etc/$WEB_SYSTEM/*.conf $HESTIA_BACKUP/conf/$WEB_SYSTEM/
359-
cp -f /etc/$WEB_SYSTEM/conf.d/*.conf $HESTIA_BACKUP/conf/$WEB_SYSTEM/
376+
cp -fr /etc/$WEB_SYSTEM/* $HESTIA_BACKUP/conf/$WEB_SYSTEM/
360377
fi
361378
if [ ! -z "$PROXY_SYSTEM" ]; then
362379
if [ "$DEBUG_MODE" = "true" ]; then
363380
echo " ---- $PROXY_SYSTEM"
364381
fi
365-
cp -f /etc/$PROXY_SYSTEM/*.conf $HESTIA_BACKUP/conf/$PROXY_SYSTEM/
366-
cp -f /etc/$PROXY_SYSTEM/conf.d/*.conf $HESTIA_BACKUP/conf/$PROXY_SYSTEM/
367-
cp -f /etc/$PROXY_SYSTEM/conf.d/*.inc $HESTIA_BACKUP/conf/$PROXY_SYSTEM/
382+
cp -fr /etc/$PROXY_SYSTEM/* $HESTIA_BACKUP/conf/$PROXY_SYSTEM/
368383
fi
369384
if [ ! -z "$IMAP_SYSTEM" ]; then
370385
if [ "$DEBUG_MODE" = "true" ]; then
371386
echo " ---- $IMAP_SYSTEM"
372387
fi
373-
cp -f /etc/$IMAP_SYSTEM/*.conf $HESTIA_BACKUP/conf/$IMAP_SYSTEM/
374-
cp -f /etc/$IMAP_SYSTEM/conf.d/*.conf $HESTIA_BACKUP/conf/$IMAP_SYSTEM/
388+
cp -fr /etc/$IMAP_SYSTEM/* $HESTIA_BACKUP/conf/$IMAP_SYSTEM/
375389
fi
376390
if [ ! -z "$MAIL_SYSTEM" ]; then
377391
if [ "$DEBUG_MODE" = "true" ]; then
378392
echo " ---- $MAIL_SYSTEM"
379393
fi
380-
cp -f /etc/$MAIL_SYSTEM/*.conf $HESTIA_BACKUP/conf/$MAIL_SYSTEM/
394+
cp -fr /etc/$MAIL_SYSTEM/* $HESTIA_BACKUP/conf/$MAIL_SYSTEM/
381395
fi
382396
if [ ! -z "$DNS_SYSTEM" ]; then
383397
if [ "$DNS_SYSTEM" = "bind9" ]; then
384398
if [ "$DEBUG_MODE" = "true" ]; then
385399
echo " ---- $DNS_SYSTEM"
386400
fi
387-
cp -f /etc/bind/*.conf $HESTIA_BACKUP/conf/$DNS_SYSTEM/
401+
cp -fr /etc/bind/* $HESTIA_BACKUP/conf/$DNS_SYSTEM/
388402
fi
389403
fi
390404
if [ ! -z "$DB_SYSTEM" ]; then
391405
if [[ "$DB_SYSTEM" =~ "mysql" ]]; then
392406
if [ "$DEBUG_MODE" = "true" ]; then
393407
echo " ---- mysql"
394408
fi
395-
cp -f /etc/mysql/*.cnf $HESTIA_BACKUP/conf/mysql/
396-
if [ -d "/etc/mysql/conf.d/" ]; then
397-
cp -f /etc/mysql/conf.d/*.cnf $HESTIA_BACKUP/conf/mysql/ > /dev/null 2>&1
398-
fi
399-
if [ -d "/etc/mysql/mariadb.conf.d/" ]; then
400-
cp -f /etc/mysql/mariadb.conf.d/*.cnf $HESTIA_BACKUP/conf/mysql/ > /dev/null 2>&1
401-
fi
409+
cp -fr /etc/mysql/* $HESTIA_BACKUP/conf/mysql/
402410
fi
403411
if [[ "$DB_SYSTEM" =~ "pgsql" ]]; then
404412
if [ "$DEBUG_MODE" = "true" ]; then
405413
echo " ---- pgsql"
406414
fi
407-
cp -f /etc/mysql/*.cnf $HESTIA_BACKUP/conf/pgsql/
408-
cp -f /etc/mysql/conf.d/*.cnf $HESTIA_BACKUP/conf/pgsql/
415+
# config for postgresql is stored in /etc/postgresql/version/main/
416+
cp -fr /etc/postgresql/* $HESTIA_BACKUP/conf/pgsql/
409417
fi
410418
fi
411419
if [ ! -z "$FTP_SYSTEM" ]; then
@@ -431,8 +439,27 @@ upgrade_start_backup() {
431439
if [ "$DEBUG_MODE" = "true" ]; then
432440
echo " ---- sshd"
433441
fi
434-
cp -f /etc/ssh/sshd_config $HESTIA_BACKUP/conf/ssh/sshd_config
442+
cp -f /etc/ssh/* $HESTIA_BACKUP/conf/ssh/
435443
fi
444+
if [ -d "/etc/roundcube" ]; then
445+
if [ "$DEBUG_MODE" = "true" ]; then
446+
echo " ---- Roundcube"
447+
fi
448+
cp -fr /etc/roundcube/* $HESTIA_BACKUP/conf/roundcube
449+
fi
450+
if [ -d "/etc/rainloop" ]; then
451+
if [ "$DEBUG_MODE" = "true" ]; then
452+
echo " ---- Rainloop"
453+
fi
454+
cp -fr /etc/roundcube/* $HESTIA_BACKUP/conf/roundcube
455+
fi
456+
if [ -d "/etc/phpmyadmin" ]; then
457+
if [ "$DEBUG_MODE" = "true" ]; then
458+
echo " ---- PHPmyAdmin"
459+
fi
460+
cp -fr /etc/phpmyadmin/* $HESTIA_BACKUP/conf/phpmyadmin
461+
fi
462+
436463
}
437464

438465
upgrade_refresh_config() {

install/upgrade/upgrade.conf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
# Update default templates when performing an upgrade
2222
# These flags should be set to true if any changes are made to the template files
2323
# to ensure that they are properly updated on the end-user's system.
24-
UPGRADE_UPDATE_WEB_TEMPLATES='true'
25-
UPGRADE_UPDATE_MAIL_TEMPLATES='true'
26-
UPGRADE_UPDATE_DNS_TEMPLATES='true'
24+
UPGRADE_UPDATE_WEB_TEMPLATES='false'
25+
UPGRADE_UPDATE_MAIL_TEMPLATES='false'
26+
UPGRADE_UPDATE_DNS_TEMPLATES='false'
2727

2828
# Update phpMyAdmin to the latest version during upgrade
29-
UPGRADE_UPDATE_PHPMYADMIN='true'
29+
UPGRADE_UPDATE_PHPMYADMIN='false'
3030

3131
# Update roundcube to the latest version during upgrade
32-
UPGRADE_UPDATE_ROUNDCUBE='true'
32+
UPGRADE_UPDATE_ROUNDCUBE='false'
3333

3434
# Update rainloop to the latest version during upgrade
3535
UPGRADE_UPDATE_RAINLOOP='true'
@@ -41,9 +41,9 @@ UPGRADE_UPDATE_FILEMANAGER='true'
4141
UPGRADE_UPDATE_FILEMANAGER_CONFIG='false'
4242

4343
# Post installation clean-up
44-
UPGRADE_REPLACE_KNOWN_KEYS='true'
45-
UPGRADE_REBUILD_USERS='true'
46-
UPGRADE_RESTART_SERVICES='true'
44+
UPGRADE_REPLACE_KNOWN_KEYS='false'
45+
UPGRADE_REBUILD_USERS='false'
46+
UPGRADE_RESTART_SERVICES='false'
4747

4848
#######################################################################################
4949
####### 3rd Party Software Updates #######

install/upgrade/versions/1.4.13.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,22 @@
55
#######################################################################################
66
####### Place additional commands below. #######
77
#######################################################################################
8-
####### New Feature: UPGRADE_MESSAGE #######
8+
####### Pass trough information to the end user incase of a issue or problem #######
99
####### #######
10-
####### Add your text to UPGRADE_MESSAGE to include a message to the upgrade #######
11-
####### email. Do not overwrite the variable, it could already contains prior #######
12-
####### content of another upgrade script. Please add it using: #######
10+
####### Use add_upgrade_message "My message here" to include a message #######
11+
####### to the upgrade email. Please add it using: #######
1312
####### #######
14-
####### UPGRADE_MESSAGE="$UPGRADE_MESSAGE\nYour Upgrade Notification Text" #######
13+
####### add_upgrade_message "My message here" #######
1514
####### #######
16-
####### Always start and end with \n to generate a new line. #######
15+
####### Use again to create a new line #######
1716
#######################################################################################
1817

1918

2019
servername=$(hostname -f);
2120
# Check if hostname is valid according to RFC1178
2221
if [[ $(echo "$servername" | grep -o "\." | wc -l) -lt 2 ]] || [[ $servername =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
2322
echo "[ * ] Hostname does not follow RFC1178 standard Please check email send regarding the update!"
24-
UPGRADE_MESSAGE="$UPGRADE_MESSAGE\nWe've noticed that you're using a invalid hostname. Please have a look at the RFC1178 standard (https://datatracker.ietf.org/doc/html/rfc1178) and use a valid one (ex. hostname.domain.tld). You can change the hostname using v-change-sys-hostname and also add a ssl certificate using v-add-letsencypt-host (proper dns A record mandatory). You'll find more informations in our documentation: https://docs.hestiacp.com/admin_docs/web/ssl_certificates.html#how-to-setup-let-s-encrypt-for-the-control-panel"
23+
add_upgrade_message "We've noticed that you're using a invalid hostname. Please have a look at the RFC1178 standard (https://datatracker.ietf.org/doc/html/rfc1178) and use a valid one (ex. hostname.domain.tld). You can change the hostname using v-change-sys-hostname and also add a ssl certificate using v-add-letsencypt-host (proper dns A record mandatory). You'll find more informations in our documentation: https://docs.hestiacp.com/admin_docs/web/ssl_certificates.html#how-to-setup-let-s-encrypt-for-the-control-panel"
2524
$HESTIA/bin/v-add-user-notification admin "Invalid Hostname detected" "Warning: We've noticed that you're using a invalid hostname. Please have a look at the <a href=\"https://datatracker.ietf.org/doc/html/rfc1178\" target=\"_blank\">RFC1178 standard</a> and use a valid one (ex. hostname.domain.tld). You can change the hostname using v-change-sys-hostname and also add a ssl certificate using v-add-letsencypt-host (proper dns A record mandatory). You'll find more informations in our <a href=\"https://docs.hestiacp.com/admin_docs/web/ssl_certificates.html#how-to-setup-let-s-encrypt-for-the-control-panel\" target=\"_blank\">documentation</a>."
2625
fi
2726

install/upgrade/versions/1.4.14.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# Hestia Control Panel upgrade script for target version 1.4.14
4+
5+
#######################################################################################
6+
####### Place additional commands below. #######
7+
#######################################################################################
8+
####### Pass trough information to the end user incase of a issue or problem #######
9+
####### #######
10+
####### Use add_upgrade_message "My message here" to include a message #######
11+
####### to the upgrade email. Please add it using: #######
12+
####### #######
13+
####### add_upgrade_message "My message here" #######
14+
####### #######
15+
####### You can use \n within the string to create new lines. #######
16+
#######################################################################################
17+

0 commit comments

Comments
 (0)