Просмотр исходного кода

Add add_upgrade_message instead old method (#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>
Jaap Marcus 4 лет назад
Родитель
Сommit
5a6ee559e3
4 измененных файлов с 79 добавлено и 36 удалено
  1. 48 21
      func/upgrade.sh
  2. 8 8
      install/upgrade/upgrade.conf
  3. 6 7
      install/upgrade/versions/1.4.13.sh
  4. 17 0
      install/upgrade/versions/1.4.14.sh

+ 48 - 21
func/upgrade.sh

@@ -9,6 +9,15 @@ source $HESTIA/func/syshealth.sh
 #######                Functions & Initialization             #######
 #######                Functions & Initialization             #######
 #####################################################################
 #####################################################################
 
 
+add_upgrade_message (){ 
+    if [ -f "$HESTIA_BACKUP/message.log" ]; then 
+        echo -e $1 >> $HESTIA_BACKUP/message.log
+        echo -e "\n\n" >> $HESTIA_BACKUP/message.log
+    else
+        echo -e $1 > $HESTIA_BACKUP/message.log
+    fi    
+}
+
 is_debug_build() {
 is_debug_build() {
     if [[ "$new_version" =~ "alpha" ]] || [[ "$new_version" =~ "beta" ]]; then
     if [[ "$new_version" =~ "alpha" ]] || [[ "$new_version" =~ "beta" ]]; then
         DEBUG_MODE="true"
         DEBUG_MODE="true"
@@ -193,11 +202,11 @@ upgrade_send_notification_to_email () {
         echo "" >> $message_tmp_file
         echo "" >> $message_tmp_file
 
 
         # Check for additional upgrade notes from update scripts.
         # Check for additional upgrade notes from update scripts.
-        if [[ -z "$UPGRADE_MESSAGE" ]]; then
+        if [[ -f "$HESTIA_BACKUP/message.log" ]]; then
             echo "==================================================="  >> $message_tmp_file
             echo "==================================================="  >> $message_tmp_file
             echo "The upgrade script has generated additional notifications, which must be heeded urgently:" >> $message_tmp_file
             echo "The upgrade script has generated additional notifications, which must be heeded urgently:" >> $message_tmp_file
             echo "" >> $message_tmp_file
             echo "" >> $message_tmp_file
-            echo -e $UPGRADE_MESSAGE >> $message_tmp_file
+            cat $HESTIA_BACKUP/message.log >> $message_tmp_file
             echo "" >> $message_tmp_file
             echo "" >> $message_tmp_file
             echo "==================================================="  >> $message_tmp_file
             echo "==================================================="  >> $message_tmp_file
             echo "" >> $message_tmp_file
             echo "" >> $message_tmp_file
@@ -307,6 +316,15 @@ upgrade_init_backup() {
     if [ -e "/etc/ssh/sshd_config" ]; then
     if [ -e "/etc/ssh/sshd_config" ]; then
         mkdir -p $HESTIA_BACKUP/conf/ssh/
         mkdir -p $HESTIA_BACKUP/conf/ssh/
     fi
     fi
+    if [ -d "/etc/roundcube/" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/roundcube/
+    fi
+    if [ -d "/etc/rainloop/" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/rainloop/
+    fi
+    if [ -d "/etc/phpmyadmin/" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/phpmyadmin/
+    fi
 }
 }
 
 
 upgrade_init_logging() {
 upgrade_init_logging() {
@@ -355,36 +373,32 @@ upgrade_start_backup() {
         if [ "$DEBUG_MODE" = "true" ]; then
         if [ "$DEBUG_MODE" = "true" ]; then
             echo "      ---- $WEB_SYSTEM"
             echo "      ---- $WEB_SYSTEM"
         fi
         fi
-        cp -f /etc/$WEB_SYSTEM/*.conf $HESTIA_BACKUP/conf/$WEB_SYSTEM/
-        cp -f /etc/$WEB_SYSTEM/conf.d/*.conf $HESTIA_BACKUP/conf/$WEB_SYSTEM/
+        cp -fr /etc/$WEB_SYSTEM/* $HESTIA_BACKUP/conf/$WEB_SYSTEM/
     fi
     fi
     if [ ! -z "$PROXY_SYSTEM" ]; then
     if [ ! -z "$PROXY_SYSTEM" ]; then
         if [ "$DEBUG_MODE" = "true" ]; then
         if [ "$DEBUG_MODE" = "true" ]; then
             echo "      ---- $PROXY_SYSTEM"
             echo "      ---- $PROXY_SYSTEM"
         fi
         fi
-        cp -f /etc/$PROXY_SYSTEM/*.conf $HESTIA_BACKUP/conf/$PROXY_SYSTEM/
-        cp -f /etc/$PROXY_SYSTEM/conf.d/*.conf $HESTIA_BACKUP/conf/$PROXY_SYSTEM/
-        cp -f /etc/$PROXY_SYSTEM/conf.d/*.inc $HESTIA_BACKUP/conf/$PROXY_SYSTEM/
+        cp -fr /etc/$PROXY_SYSTEM/* $HESTIA_BACKUP/conf/$PROXY_SYSTEM/
     fi
     fi
     if [ ! -z "$IMAP_SYSTEM" ]; then
     if [ ! -z "$IMAP_SYSTEM" ]; then
         if [ "$DEBUG_MODE" = "true" ]; then
         if [ "$DEBUG_MODE" = "true" ]; then
             echo "      ---- $IMAP_SYSTEM"
             echo "      ---- $IMAP_SYSTEM"
         fi
         fi
-        cp -f /etc/$IMAP_SYSTEM/*.conf $HESTIA_BACKUP/conf/$IMAP_SYSTEM/
-        cp -f /etc/$IMAP_SYSTEM/conf.d/*.conf $HESTIA_BACKUP/conf/$IMAP_SYSTEM/
+        cp -fr /etc/$IMAP_SYSTEM/* $HESTIA_BACKUP/conf/$IMAP_SYSTEM/
     fi
     fi
     if [ ! -z "$MAIL_SYSTEM" ]; then
     if [ ! -z "$MAIL_SYSTEM" ]; then
         if [ "$DEBUG_MODE" = "true" ]; then
         if [ "$DEBUG_MODE" = "true" ]; then
             echo "      ---- $MAIL_SYSTEM"
             echo "      ---- $MAIL_SYSTEM"
         fi
         fi
-        cp -f /etc/$MAIL_SYSTEM/*.conf $HESTIA_BACKUP/conf/$MAIL_SYSTEM/
+        cp -fr /etc/$MAIL_SYSTEM/* $HESTIA_BACKUP/conf/$MAIL_SYSTEM/
     fi
     fi
     if [ ! -z "$DNS_SYSTEM" ]; then
     if [ ! -z "$DNS_SYSTEM" ]; then
         if [ "$DNS_SYSTEM" = "bind9" ]; then
         if [ "$DNS_SYSTEM" = "bind9" ]; then
             if [ "$DEBUG_MODE" = "true" ]; then
             if [ "$DEBUG_MODE" = "true" ]; then
                 echo "      ---- $DNS_SYSTEM"
                 echo "      ---- $DNS_SYSTEM"
             fi
             fi
-            cp -f /etc/bind/*.conf $HESTIA_BACKUP/conf/$DNS_SYSTEM/
+            cp -fr /etc/bind/* $HESTIA_BACKUP/conf/$DNS_SYSTEM/
         fi
         fi
     fi
     fi
     if [ ! -z "$DB_SYSTEM" ]; then
     if [ ! -z "$DB_SYSTEM" ]; then
@@ -392,20 +406,14 @@ upgrade_start_backup() {
             if [ "$DEBUG_MODE" = "true" ]; then
             if [ "$DEBUG_MODE" = "true" ]; then
                 echo "      ---- mysql"
                 echo "      ---- mysql"
             fi
             fi
-            cp -f /etc/mysql/*.cnf $HESTIA_BACKUP/conf/mysql/
-            if [ -d "/etc/mysql/conf.d/" ]; then
-            cp -f /etc/mysql/conf.d/*.cnf $HESTIA_BACKUP/conf/mysql/ > /dev/null 2>&1
-            fi
-            if [ -d "/etc/mysql/mariadb.conf.d/" ]; then
-            cp -f /etc/mysql/mariadb.conf.d/*.cnf $HESTIA_BACKUP/conf/mysql/ > /dev/null 2>&1
-            fi       
+            cp -fr /etc/mysql/* $HESTIA_BACKUP/conf/mysql/       
         fi
         fi
         if [[ "$DB_SYSTEM" =~ "pgsql" ]]; then
         if [[ "$DB_SYSTEM" =~ "pgsql" ]]; then
             if [ "$DEBUG_MODE" = "true" ]; then
             if [ "$DEBUG_MODE" = "true" ]; then
                 echo "      ---- pgsql"
                 echo "      ---- pgsql"
             fi
             fi
-            cp -f /etc/mysql/*.cnf $HESTIA_BACKUP/conf/pgsql/
-            cp -f /etc/mysql/conf.d/*.cnf $HESTIA_BACKUP/conf/pgsql/         
+            # config for postgresql is stored in /etc/postgresql/version/main/
+            cp -fr /etc/postgresql/* $HESTIA_BACKUP/conf/pgsql/         
         fi
         fi
     fi
     fi
     if [ ! -z "$FTP_SYSTEM" ]; then
     if [ ! -z "$FTP_SYSTEM" ]; then
@@ -431,8 +439,27 @@ upgrade_start_backup() {
         if [ "$DEBUG_MODE" = "true" ]; then
         if [ "$DEBUG_MODE" = "true" ]; then
             echo "      ---- sshd"
             echo "      ---- sshd"
         fi
         fi
-        cp -f /etc/ssh/sshd_config $HESTIA_BACKUP/conf/ssh/sshd_config
+        cp -f /etc/ssh/* $HESTIA_BACKUP/conf/ssh/
     fi
     fi
+    if [ -d "/etc/roundcube" ]; then
+        if [ "$DEBUG_MODE" = "true" ]; then
+            echo "      ---- Roundcube"
+        fi
+        cp -fr /etc/roundcube/* $HESTIA_BACKUP/conf/roundcube
+    fi
+    if [ -d "/etc/rainloop" ]; then
+        if [ "$DEBUG_MODE" = "true" ]; then
+            echo "      ---- Rainloop"
+        fi
+        cp -fr /etc/roundcube/* $HESTIA_BACKUP/conf/roundcube
+    fi
+    if [ -d "/etc/phpmyadmin" ]; then
+        if [ "$DEBUG_MODE" = "true" ]; then
+            echo "      ---- PHPmyAdmin"
+        fi
+        cp -fr /etc/phpmyadmin/* $HESTIA_BACKUP/conf/phpmyadmin
+    fi
+
 }
 }
 
 
 upgrade_refresh_config() {
 upgrade_refresh_config() {

+ 8 - 8
install/upgrade/upgrade.conf

@@ -21,15 +21,15 @@
 # Update default templates when performing an upgrade
 # Update default templates when performing an upgrade
 # These flags should be set to true if any changes are made to the template files
 # These flags should be set to true if any changes are made to the template files
 # to ensure that they are properly updated on the end-user's system.
 # to ensure that they are properly updated on the end-user's system.
-UPGRADE_UPDATE_WEB_TEMPLATES='true'
-UPGRADE_UPDATE_MAIL_TEMPLATES='true'
-UPGRADE_UPDATE_DNS_TEMPLATES='true'
+UPGRADE_UPDATE_WEB_TEMPLATES='false'
+UPGRADE_UPDATE_MAIL_TEMPLATES='false'
+UPGRADE_UPDATE_DNS_TEMPLATES='false'
 
 
 # Update phpMyAdmin to the latest version during upgrade
 # Update phpMyAdmin to the latest version during upgrade
-UPGRADE_UPDATE_PHPMYADMIN='true'
+UPGRADE_UPDATE_PHPMYADMIN='false'
 
 
 # Update roundcube to the latest version during upgrade
 # Update roundcube to the latest version during upgrade
-UPGRADE_UPDATE_ROUNDCUBE='true'
+UPGRADE_UPDATE_ROUNDCUBE='false'
 
 
 # Update rainloop to the latest version during upgrade
 # Update rainloop to the latest version during upgrade
 UPGRADE_UPDATE_RAINLOOP='true'
 UPGRADE_UPDATE_RAINLOOP='true'
@@ -41,9 +41,9 @@ UPGRADE_UPDATE_FILEMANAGER='true'
 UPGRADE_UPDATE_FILEMANAGER_CONFIG='false'
 UPGRADE_UPDATE_FILEMANAGER_CONFIG='false'
 
 
 # Post installation clean-up
 # Post installation clean-up
-UPGRADE_REPLACE_KNOWN_KEYS='true'
-UPGRADE_REBUILD_USERS='true'
-UPGRADE_RESTART_SERVICES='true'
+UPGRADE_REPLACE_KNOWN_KEYS='false'
+UPGRADE_REBUILD_USERS='false'
+UPGRADE_RESTART_SERVICES='false'
 
 
 #######################################################################################
 #######################################################################################
 #######                        3rd Party Software Updates                       #######
 #######                        3rd Party Software Updates                       #######

+ 6 - 7
install/upgrade/versions/1.4.13.sh

@@ -5,15 +5,14 @@
 #######################################################################################
 #######################################################################################
 #######                      Place additional commands below.                   #######
 #######                      Place additional commands below.                   #######
 #######################################################################################
 #######################################################################################
-####### New Feature: UPGRADE_MESSAGE                                            #######
+####### Pass trough information to the end user incase of a issue or problem    #######
 #######                                                                         #######
 #######                                                                         #######
-####### Add your text to UPGRADE_MESSAGE to include a message to the upgrade    #######
-####### email. Do not overwrite the variable, it could already contains prior   #######
-####### content of another upgrade script. Please add it using:                 #######
+####### Use add_upgrade_message "My message here" to include a message          #######
+####### to the upgrade email. Please add it using:                              #######
 #######                                                                         #######
 #######                                                                         #######
-####### UPGRADE_MESSAGE="$UPGRADE_MESSAGE\nYour Upgrade Notification Text"      #######
+####### add_upgrade_message "My message here"                                   #######
 #######                                                                         #######
 #######                                                                         #######
-####### Always start and end with \n to generate a new line.                    #######
+####### Use again to create a new line                                          #######
 #######################################################################################
 #######################################################################################
 
 
 
 
@@ -21,7 +20,7 @@ servername=$(hostname -f);
 # Check if hostname is valid according to RFC1178
 # Check if hostname is valid according to RFC1178
 if [[ $(echo "$servername" | grep -o "\." | wc -l) -lt 2 ]] || [[ $servername =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
 if [[ $(echo "$servername" | grep -o "\." | wc -l) -lt 2 ]] || [[ $servername =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
     echo "[ * ] Hostname does not follow  RFC1178 standard Please check email send regarding the update!"
     echo "[ * ] Hostname does not follow  RFC1178 standard Please check email send regarding the update!"
-    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"
+    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"
     $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>."
     $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>."
 fi
 fi
 
 

+ 17 - 0
install/upgrade/versions/1.4.14.sh

@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# Hestia Control Panel upgrade script for target version 1.4.14
+
+#######################################################################################
+#######                      Place additional commands below.                   #######
+#######################################################################################
+####### Pass trough information to the end user incase of a issue or problem    #######
+#######                                                                         #######
+####### Use add_upgrade_message "My message here" to include a message          #######
+####### to the upgrade email. Please add it using:                              #######
+#######                                                                         #######
+####### add_upgrade_message "My message here"                                   #######
+#######                                                                         #######
+####### You can use \n within the string to create new lines.                   #######
+#######################################################################################
+