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

Version bump: Hestia Control Panel v1.2.2 (development)

Kristan Kenney 5 лет назад
Родитель
Сommit
386a8e483e

+ 1 - 1
CHANGELOG.md

@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
 ### Features
 
 ### Bugfixes
-- Improved quality of default web domain templates for Drupal.
+
  
 ## [1.2.1] - Service Release 1 (beta)
 ### Features

+ 2 - 0
README.md

@@ -3,6 +3,8 @@
 [Hestia Control Panel](https://www.hestiacp.com/)
 ==================================================
 **Latest stable release:** Version 1.2.0 | [View Changelog](https://github.com/hestiacp/hestiacp/blob/release/CHANGELOG.md)<br>
+**Latest beta release:** Version 1.2.1 | [View Changelog](https://github.com/hestiacp/hestiacp/blob/beta/CHANGELOG.md)<br>
+**Latest unstable development snapshot:** Version 1.2.2 | [View Changelog](https://github.com/hestiacp/hestiacp/main/release/CHANGELOG.md)<br>
 
 **Web:** [www.hestiacp.com](https://www.hestiacp.com/)<br>
 **Documentation:** [docs.hestiacp.com](https://docs.hestiacp.com/)<br>

+ 107 - 1
func/upgrade.sh

@@ -61,9 +61,92 @@ upgrade_complete_message() {
 
 upgrade_init_backup() {
     # Ensure that backup directories are created
-    mkdir -p $HESTIA_BACKUP/conf/
+    # Hestia Control Panel configuration files
+    mkdir -p $HESTIA_BACKUP/conf/hestia/
+    
+    # Hosting Packages
     mkdir -p $HESTIA_BACKUP/packages/
+
+    # Domain template files
     mkdir -p $HESTIA_BACKUP/templates/
+
+    # System services (apache2, nginx, bind9, vsftpd, etc).
+    if [ ! -z "$WEB_SYSTEM" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/$WEB_SYSTEM/
+    fi
+    if [ ! -z "$IMAP_SYSTEM" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/$IMAP_SYSTEM/
+    fi
+    if [ ! -z "$MAIL_SYSTEM" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/$MAIL_SYSTEM/
+    fi
+    if [ ! -z "$DNS_SYSTEM" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/$DNS_SYSTEM/
+    fi
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/$PROXY_SYSTEM/
+    fi
+    if [ ! -z "$DB_SYSTEM" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/$DB_SYSTEM/
+    fi
+    if [ ! -z "$FTP_SYSTEM" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/$FTP_SYSTEM/
+    fi
+    if [ ! -z "$FIREWALL_SYSTEM" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/$FIREWALL_SYSTEM/
+    fi
+    if [ ! -z "$FIREWALL_EXTENSION" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/$FIREWALL_EXTENSION/
+    fi
+    if [ -e "/etc/ssh/sshd_config" ]; then
+        mkdir -p $HESTIA_BACKUP/conf/ssh/
+    fi
+
+    echo "[ * ] Backing up existing templates and configuration files..."
+
+    cp -rf $HESTIA/data/packages/* $HESTIA_BACKUP/packages/
+
+    cp -rf $HESTIA/data/templates/* $HESTIA_BACKUP/templates/
+
+    # Hestia Control Panel configuration files
+    cp -rf $HESTIA/conf/* $HESTIA_BACKUP/conf/hestia/
+
+    # System service configuration files (apache2, nginx, bind9, vsftpd, etc).
+    if [ ! -z "$WEB_SYSTEM" ]; then
+        cp -f /etc/$WEB_SYSTEM/*.conf $HESTIA_BACKUP/conf/$WEB_SYSTEM/
+        cp -f /etc/$WEB_SYSTEM/conf.d/*.conf $HESTIA_BACKUP/conf/$WEB_SYSTEM/
+    fi
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        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/
+    fi
+    if [ ! -z "$IMAP_SYSTEM" ]; then
+        cp -f /etc/$IMAP_SYSTEM/*.conf $HESTIA_BACKUP/conf/$IMAP_SYSTEM/
+        cp -f /etc/$IMAP_SYSTEM/conf.d/*.conf $HESTIA_BACKUP/conf/$IMAP_SYSTEM/
+    fi
+    if [ ! -z "$MAIL_SYSTEM" ]; then
+        cp -f /etc/$MAIL_SYSTEM/*.conf $HESTIA_BACKUP/conf/$MAIL_SYSTEM/
+    fi
+    if [ ! -z "$DNS_SYSTEM" ]; then
+        if [ "$DNS_SYSTEM" = "bind9" ]; then
+            cp -f /etc/bind/*.conf $HESTIA_BACKUP/conf/$DNS_SYSTEM/
+        fi
+    fi
+    if [ ! -z "$DB_SYSTEM" ]; then
+        cp -f /etc/$DB_SYSTEM/*.cnf $HESTIA_BACKUP/conf/$DB_SYSTEM/
+        cp -f /etc/$DB_SYSTEM/conf.d/*.cnf $HESTIA_BACKUP/conf/$DB_SYSTEM/
+    fi
+    if [ ! -z "$FTP_SYSTEM" ]; then
+        cp -f /etc/$FTP_SYSTEM.conf $HESTIA_BACKUP/conf/$FTP_SYSTEM/
+    fi
+    if [ ! -z "$FIREWALL_EXTENSION" ]; then
+        cp -f /etc/$FIREWALL_EXTENSION/*.conf $HESTIA_BACKUP/conf/$FIREWALL_EXTENSION/
+        cp -f /etc/$FIREWALL_EXTENSION/*.local $HESTIA_BACKUP/conf/$FIREWALL_EXTENSION/
+    fi
+    if [ -e "/etc/ssh/sshd_config" ]; then
+        cp -f /etc/ssh/sshd_config $HESTIA_BACKUP/conf/ssh/sshd_config
+    fi
 }
 
 upgrade_refresh_config() {
@@ -164,11 +247,34 @@ upgrade_start_routine() {
 
     # Upgrade to Version 1.2.0
     if [ $VERSION = "1.1.1" ] || [ $VERSION = "1.1.2" ]; then
+        source $HESTIA/install/upgrade/versions/previous/1.2.0.sh
+        VERSION="1.2.1"
+        upgrade_set_version $VERSION
+        upgrade_refresh_config
+    fi
+
+
+    # Upgrade to Version 1.2.1
+    if [ $VERSION = "1.2.0" ]; then
+        # Process steps which may not have correctly executed from v1.1.0.
+        echo
+        echo "[ ! ] Reprocessing steps from v1.1.0 due to a previous installer bug..."
+        echo
+        source $HESTIA/install/upgrade/versions/previous/1.1.0.sh
+        source $HESTIA/install/upgrade/versions/previous/1.2.0.sh
+        VERSION="1.2.1"
+        upgrade_refresh_config
+    fi
+
+
+    # Upgrade to Version 1.2.2
+    if [ $VERSION = "1.2.1" ]; then
         source $HESTIA/install/upgrade/versions/latest.sh
         VERSION="$new_version"
         upgrade_refresh_config
     fi
 
+
     #####################################################################
     #######     End version-specific upgrade instruction sets     #######
     #####################################################################

+ 1 - 1
install/hst-install-debian.sh

@@ -23,7 +23,7 @@ HESTIA_INSTALL_DIR="$HESTIA/install/deb"
 VERBOSE='no'
 
 # Define software versions
-HESTIA_INSTALL_VER='1.2.0'
+HESTIA_INSTALL_VER='1.2.2'
 pma_v='5.0.2'
 multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4")
 fpm_v="7.3"

+ 1 - 1
install/hst-install-ubuntu.sh

@@ -23,7 +23,7 @@ HESTIA_INSTALL_DIR="$HESTIA/install/deb"
 VERBOSE='no'
 
 # Define software versions
-HESTIA_INSTALL_VER='1.2.0'
+HESTIA_INSTALL_VER='1.2.2'
 pma_v='5.0.2'
 multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4")
 fpm_v="7.3"

+ 1 - 213
install/upgrade/versions/latest.sh

@@ -1,223 +1,11 @@
 #!/bin/sh
 
-# Hestia Control Panel upgrade script for target version 1.2.0
+# Hestia Control Panel upgrade script for target version 1.2.2
 
 #######################################################################################
 #######                      Place additional commands below.                   #######
 #######################################################################################
 
-# Check iptables paths and add symlinks when necessary
-
-if [ ! -e "/sbin/iptables" ]; then
-    if which iptables; then
-        ln -s "$(which iptables)" /sbin/iptables
-    elif [ -e "/usr/sbin/iptables" ]; then
-        ln -s /usr/sbin/iptables /sbin/iptables
-    elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables; then
-        autoiptables=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables | cut -d '' -f 2)
-        if [ -x "$autoiptables" ]; then
-            ln -s "$autoiptables" /sbin/iptables
-        fi
-    fi
-fi
-
-if [ ! -e "/sbin/iptables-save" ]; then
-    if which iptables-save; then
-        ln -s "$(which iptables-save)" /sbin/iptables-save
-    elif [ -e "/usr/sbin/iptables-save" ]; then
-        ln -s /usr/sbin/iptables-save /sbin/iptables-save
-    elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-save; then
-        autoiptables_save=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-save | cut -d '' -f 2)
-        if [ -x "$autoiptables_save" ]; then
-            ln -s "$autoiptables_save" /sbin/iptables-save
-        fi
-    fi
-fi
-
-if [ ! -e "/sbin/iptables-restore" ]; then
-    if which iptables-restore; then
-        ln -s "$(which iptables-restore)" /sbin/iptables-restore
-    elif [ -e "/usr/sbin/iptables-restore" ]; then
-        ln -s /usr/sbin/iptables-restore /sbin/iptables-restore
-    elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-restore; then
-        autoiptables_restore=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-restore | cut -d '' -f 2)
-        if [ -x "$autoiptables_restore" ]; then
-            ln -s "$autoiptables_restore" /sbin/iptables-restore
-        fi
-    fi
-fi
-
-if [ -e "/etc/apache2/mods-enabled/status.conf" ]; then
-    sed -i '/Allow from all/d' /etc/apache2/mods-enabled/status.conf
-fi
-
-# Add sury apache2 repository
-if [ "$WEB_SYSTEM" = "apache2" ] && [ ! -e "/etc/apt/sources.list.d/apache2.list" ]; then
-    echo "[ * ] Configuring sury.org Apache2 repository..."
-
-    # Check OS and install related repository
-    if [ -e "/etc/os-release" ]; then
-        type=$(grep "^ID=" /etc/os-release | cut -f 2 -d '=')
-        if [ "$type" = "ubuntu" ]; then
-            codename="$(lsb_release -s -c)"
-            echo "deb http://ppa.launchpad.net/ondrej/apache2/ubuntu $codename main" > /etc/apt/sources.list.d/apache2.list
-        elif [ "$type" = "debian" ]; then
-            codename="$(cat /etc/os-release |grep VERSION= |cut -f 2 -d \(|cut -f 1 -d \))"
-            echo "deb https://packages.sury.org/apache2/ $codename main" > /etc/apt/sources.list.d/apache2.list
-            wget --quiet https://packages.sury.org/apache2/apt.gpg -O /tmp/apache2_signing.key
-            APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add /tmp/apache2_signing.key > /dev/null 2>&1
-        fi
-    fi
-fi
-
-# Roundcube fixes for PHP 7.4 compatibility
-if [ -d /usr/share/roundcube ]; then
-    echo "[ * ] Updating Roundcube configuration..."
-    [ -f "/usr/share/roundcube/plugins/enigma/lib/enigma_ui.php" ] && sed -i 's/$identities, "\\n"/"\\n", $identities/g' /usr/share/roundcube/plugins/enigma/lib/enigma_ui.php
-    [ -f "/usr/share/roundcube/program/lib/Roundcube/rcube_contacts.php" ] && sed -i 's/(array_keys($post_search), \x27|\x27)/(\x27|\x27, array_keys($post_search))/g' /usr/share/roundcube/program/lib/Roundcube/rcube_contacts.php
-    [ -f "/usr/share/roundcube/program/lib/Roundcube/rcube_db.php" ] && sed -i 's/implode($name, \x27.\x27)/implode(\x27.\x27, $name)/g' /usr/share/roundcube/program/lib/Roundcube/rcube_db.php
-    [ -f "/usr/share/roundcube/program/steps/addressbook/search.inc" ] && sed -i 's/$fields, \x27,\x27/\x27,\x27, $fields/g' /usr/share/roundcube/program/steps/addressbook/search.inc
-    [ -f "/usr/share/roundcube/program/steps/addressbook/search.inc" ] && sed -i 's/implode($fields, \x27,\x27)/implode(\x27,\x27, $fields)/g' /usr/share/roundcube/program/steps/addressbook/search.inc
-    [ -f "/usr/share/roundcube/program/steps/mail/sendmail.inc" ] && sed -i 's/implode($bstyle, \x27; \x27)/implode(\x27; \x27, $bstyle)/g' /usr/share/roundcube/program/steps/mail/sendmail.inc
-fi
-
-# Enable Roundcube plugins
-if [ -d /usr/share/roundcube ]; then
-    cp -f $HESTIA_INSTALL_DIR/roundcube/plugins/config_newmail_notifier.inc.php /etc/roundcube/plugins/newmail_notifier/config.inc.php
-    cp -f $HESTIA_INSTALL_DIR/roundcube/plugins/config_zipdownload.inc.php /etc/roundcube/plugins/zipdownload/config.inc.php
-    [ -f "/etc/roundcube/config.inc.php" ] && sed -i "s/array('password')/array('password','newmail_notifier','zipdownload')/g" /etc/roundcube/config.inc.php
-fi
-
-# HELO support for multiple domains and IPs
-if [ -e "/etc/exim4/exim4.conf.template" ]; then
-    echo "[ * ] Updating exim4 configuration..."
-    sed -i 's|helo_data = ${primary_hostname}|helo_data = ${if exists {\/etc\/exim4\/mailhelo.conf}{${lookup{$sender_address_domain}lsearch*{\/etc\/exim4\/mailhelo.conf}{$value}{$primary_hostname}}}{$primary_hostname}}|g' /etc/exim4/exim4.conf.template
-fi
-
-# Add daily midnight cron
-if [ -z "$($BIN/v-list-cron-jobs admin | grep 'v-update-sys-queue daily')" ]; then
-    echo "[ * ] Updating cron jobs..."
-    command="sudo $BIN/v-update-sys-queue daily"
-    $BIN/v-add-cron-job 'admin' '01' '00' '*' '*' '*' "$command"
-fi
-[ ! -f "touch $HESTIA/data/queue/daily.pipe" ] && touch $HESTIA/data/queue/daily.pipe
-
-# Remove existing network-up hooks so they get regenerated when updating the firewall
-# - network hook will also restore ipset config during start-up
-if [ -f "/usr/lib/networkd-dispatcher/routable.d/50-ifup-hooks" ]; then
-    rm "/usr/lib/networkd-dispatcher/routable.d/50-ifup-hooks"
-    $BIN/v-update-firewall
-fi
-if [ -f "/etc/network/if-pre-up.d/iptables" ];then
-    rm "/etc/network/if-pre-up.d/iptables"
-    $BIN/v-update-firewall
-fi
-
-# Add hestia-event.conf, if the server is running apache2
-if [ "$WEB_SYSTEM" = "apache2" ]; then
-    echo "[ * ] Updating Apache2 configuration..."
-    # Cleanup
-    rm --force /etc/apache2/mods-available/hestia-event.conf
-    rm --force /etc/apache2/mods-enabled/hestia-event.conf
-    rm --force /etc/apache2/conf-available/hestia-event.conf
-    rm --force /etc/apache2/conf-enabled/hestia-event.conf
-
-    if [ $(a2query -M) = 'event' ] && [ ! -e "/etc/apache2/conf.d/hestia-event.conf" ]; then
-        cp -f $HESTIA_INSTALL_DIR/apache2/hestia-event.conf /etc/apache2/conf.d/
-    fi
-
-    # Move apache mod_status config to /mods-available and rename it to prevent losing changes on upgrade
-    cp -f $HESTIA_INSTALL_DIR/apache2/status.conf /etc/apache2/mods-available/hestia-status.conf
-    cp -f /etc/apache2/mods-available/status.load /etc/apache2/mods-available/hestia-status.load
-    a2dismod --quiet status > /dev/null 2>&1
-    a2enmod --quiet hestia-status > /dev/null 2>&1
-    rm --force /etc/apache2/mods-enabled/status.conf # a2dismod will not remove the file if it isn't a symlink
-fi
-
-# Install File Manager during upgrade if environment variable oesn't already exist and isn't set to false
-# so that we don't override preference
-FILE_MANAGER_CHECK=$(cat $HESTIA/conf/hestia.conf | grep "FILE_MANAGER='false'")
-if [ -z "$FILE_MANAGER_CHECK" ]; then
-    if [ ! -e "$HESTIA/web/fm/configuration.php" ]; then
-        echo "[ ! ] Installing File Manager..."
-        # Install the File Manager
-        $HESTIA/bin/v-add-sys-filemanager quiet
-    else 
-        echo "[ * ] Updating File Manager configuration..."
-        # Update configuration.php
-        cp -f $HESTIA_INSTALL_DIR/filemanager/filegator/configuration.php $HESTIA/web/fm/configuration.php
-        # Set environment variable for interface
-        $HESTIA/bin/v-change-sys-config-value 'FILE_MANAGER' 'true'
-    fi
-fi
-
-# Enable nginx module loading
-if [ -f "/etc/nginx/nginx.conf" ]; then
-    echo "[ * ] Updating NGINX configuration..."
-    if [ ! -d "/etc/nginx/modules-enabled" ]; then
-        mkdir -p "/etc/nginx/modules-enabled"
-    fi
-
-    if ! grep --silent "include /etc/nginx/modules-enabled" /etc/nginx/nginx.conf; then
-        sed -i '/^pid/ a include /etc/nginx/modules-enabled/*.conf;' /etc/nginx/nginx.conf
-    fi
-fi
-
-# Fix public_(s)html group ownership
-echo "[ * ] Updating public_(s)html ownership..."
-for user in $($HESTIA/bin/v-list-sys-users plain); do
-    # skip users with missing home folder
-    [[ -d /home/${user}/ ]] || continue
-
-    # skip users without web domains
-    ls /home/${user}/web/*/public_*html >/dev/null 2>&1 || continue
-
-    chown --silent --no-dereference :www-data /home/$user/web/*/public_*html
-done
-
-# Fix phpMyAdmin blowfish_secret error message due to incorrect permissions
-if [ -e /var/lib/phpmyadmin/blowfish_secret.inc.php ]; then
-    echo "[ * ] Updating phpMyAdmin permissions..."
-    chmod 0644 /var/lib/phpmyadmin/blowfish_secret.inc.php
-fi
-
-# Ensure that backup compression level is correctly set
-GZIP_LVL_CHECK=$(cat $HESTIA/conf/hestia.conf | grep BACKUP_GZIP)
-if [ -z "$GZIP_LVL_CHECK" ]; then
-    echo "[ * ] Updating backup compression level variable..."
-    $BIN/v-change-sys-config-value "BACKUP_GZIP" '9'
-fi
-
-# Update phpMyAdmin/phpPgAdmin templates and set missing alias variables if necessary
-if [ -e "/var/lib/phpmyadmin" ]; then
-    PMA_ALIAS_CHECK=$(cat $HESTIA/conf/hestia.conf | grep DB_PMA_ALIAS)
-    if [ -z "$PMA_ALIAS_CHECK" ]; then
-        echo "[ * ] Updating phpMyAdmin alias..."
-        $HESTIA/bin/v-change-sys-db-alias "pma" "phpMyAdmin"
-    else
-        echo "[ * ] Updating phpMyAdmin configuration..."
-        $HESTIA/bin/v-change-sys-db-alias "pma" "$DB_PMA_ALIAS"
-    fi
-fi
-
-if [ -e "/var/lib/phppgadmin" ]; then
-    PGA_ALIAS_CHECK=$(cat $HESTIA/conf/hestia.conf | grep DB_PGA_ALIAS)
-    if [ -z "$PGA_ALIAS_CHECK" ]; then
-        echo "[ * ] Updating phpPgAdmin alias..."
-        $HESTIA/bin/v-change-sys-db-alias "pga" "phpPgAdmin"
-    else
-        echo "[ * ] Updating phpPgAdmin configuration..."
-        $HESTIA/bin/v-change-sys-db-alias "pga" "$DB_PGA_ALIAS"
-    fi
-fi
-
-# Ensure that backup compression level is correctly set
-GZIP_LVL_CHECK=$(cat $HESTIA/conf/hestia.conf | grep BACKUP_GZIP)
-if [ -z "$GZIP_LVL_CHECK" ]; then
-    echo "[ * ] Updating backup compression level variable..."
-    $BIN/v-change-sys-config-value "BACKUP_GZIP" '9'
-fi
-
 # Update template files to add warnings
 # Backup current templates
 cp -r -f $HESTIA/data/templates/* $HESTIA_BACKUP/templates/

+ 229 - 0
install/upgrade/versions/previous/1.2.0.sh

@@ -0,0 +1,229 @@
+#!/bin/sh
+
+# Hestia Control Panel upgrade script for target version 1.2.0
+
+#######################################################################################
+#######                      Place additional commands below.                   #######
+#######################################################################################
+
+# Check iptables paths and add symlinks when necessary
+
+if [ ! -e "/sbin/iptables" ]; then
+    if which iptables; then
+        ln -s "$(which iptables)" /sbin/iptables
+    elif [ -e "/usr/sbin/iptables" ]; then
+        ln -s /usr/sbin/iptables /sbin/iptables
+    elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables; then
+        autoiptables=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables | cut -d '' -f 2)
+        if [ -x "$autoiptables" ]; then
+            ln -s "$autoiptables" /sbin/iptables
+        fi
+    fi
+fi
+
+if [ ! -e "/sbin/iptables-save" ]; then
+    if which iptables-save; then
+        ln -s "$(which iptables-save)" /sbin/iptables-save
+    elif [ -e "/usr/sbin/iptables-save" ]; then
+        ln -s /usr/sbin/iptables-save /sbin/iptables-save
+    elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-save; then
+        autoiptables_save=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-save | cut -d '' -f 2)
+        if [ -x "$autoiptables_save" ]; then
+            ln -s "$autoiptables_save" /sbin/iptables-save
+        fi
+    fi
+fi
+
+if [ ! -e "/sbin/iptables-restore" ]; then
+    if which iptables-restore; then
+        ln -s "$(which iptables-restore)" /sbin/iptables-restore
+    elif [ -e "/usr/sbin/iptables-restore" ]; then
+        ln -s /usr/sbin/iptables-restore /sbin/iptables-restore
+    elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-restore; then
+        autoiptables_restore=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-restore | cut -d '' -f 2)
+        if [ -x "$autoiptables_restore" ]; then
+            ln -s "$autoiptables_restore" /sbin/iptables-restore
+        fi
+    fi
+fi
+
+if [ -e "/etc/apache2/mods-enabled/status.conf" ]; then
+    sed -i '/Allow from all/d' /etc/apache2/mods-enabled/status.conf
+fi
+
+# Add sury apache2 repository
+if [ "$WEB_SYSTEM" = "apache2" ] && [ ! -e "/etc/apt/sources.list.d/apache2.list" ]; then
+    echo "[ * ] Configuring sury.org Apache2 repository..."
+
+    # Check OS and install related repository
+    if [ -e "/etc/os-release" ]; then
+        type=$(grep "^ID=" /etc/os-release | cut -f 2 -d '=')
+        if [ "$type" = "ubuntu" ]; then
+            codename="$(lsb_release -s -c)"
+            echo "deb http://ppa.launchpad.net/ondrej/apache2/ubuntu $codename main" > /etc/apt/sources.list.d/apache2.list
+        elif [ "$type" = "debian" ]; then
+            codename="$(cat /etc/os-release |grep VERSION= |cut -f 2 -d \(|cut -f 1 -d \))"
+            echo "deb https://packages.sury.org/apache2/ $codename main" > /etc/apt/sources.list.d/apache2.list
+            wget --quiet https://packages.sury.org/apache2/apt.gpg -O /tmp/apache2_signing.key
+            APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add /tmp/apache2_signing.key > /dev/null 2>&1
+        fi
+    fi
+fi
+
+# Roundcube fixes for PHP 7.4 compatibility
+if [ -d /usr/share/roundcube ]; then
+    echo "[ * ] Updating Roundcube configuration..."
+    [ -f "/usr/share/roundcube/plugins/enigma/lib/enigma_ui.php" ] && sed -i 's/$identities, "\\n"/"\\n", $identities/g' /usr/share/roundcube/plugins/enigma/lib/enigma_ui.php
+    [ -f "/usr/share/roundcube/program/lib/Roundcube/rcube_contacts.php" ] && sed -i 's/(array_keys($post_search), \x27|\x27)/(\x27|\x27, array_keys($post_search))/g' /usr/share/roundcube/program/lib/Roundcube/rcube_contacts.php
+    [ -f "/usr/share/roundcube/program/lib/Roundcube/rcube_db.php" ] && sed -i 's/implode($name, \x27.\x27)/implode(\x27.\x27, $name)/g' /usr/share/roundcube/program/lib/Roundcube/rcube_db.php
+    [ -f "/usr/share/roundcube/program/steps/addressbook/search.inc" ] && sed -i 's/$fields, \x27,\x27/\x27,\x27, $fields/g' /usr/share/roundcube/program/steps/addressbook/search.inc
+    [ -f "/usr/share/roundcube/program/steps/addressbook/search.inc" ] && sed -i 's/implode($fields, \x27,\x27)/implode(\x27,\x27, $fields)/g' /usr/share/roundcube/program/steps/addressbook/search.inc
+    [ -f "/usr/share/roundcube/program/steps/mail/sendmail.inc" ] && sed -i 's/implode($bstyle, \x27; \x27)/implode(\x27; \x27, $bstyle)/g' /usr/share/roundcube/program/steps/mail/sendmail.inc
+fi
+
+# Enable Roundcube plugins
+if [ -d /usr/share/roundcube ]; then
+    cp -f $HESTIA_INSTALL_DIR/roundcube/plugins/config_newmail_notifier.inc.php /etc/roundcube/plugins/newmail_notifier/config.inc.php
+    cp -f $HESTIA_INSTALL_DIR/roundcube/plugins/config_zipdownload.inc.php /etc/roundcube/plugins/zipdownload/config.inc.php
+    [ -f "/etc/roundcube/config.inc.php" ] && sed -i "s/array('password')/array('password','newmail_notifier','zipdownload')/g" /etc/roundcube/config.inc.php
+fi
+
+# HELO support for multiple domains and IPs
+if [ -e "/etc/exim4/exim4.conf.template" ]; then
+    echo "[ * ] Updating exim4 configuration..."
+    sed -i 's|helo_data = ${primary_hostname}|helo_data = ${if exists {\/etc\/exim4\/mailhelo.conf}{${lookup{$sender_address_domain}lsearch*{\/etc\/exim4\/mailhelo.conf}{$value}{$primary_hostname}}}{$primary_hostname}}|g' /etc/exim4/exim4.conf.template
+fi
+
+# Add daily midnight cron
+if [ -z "$($BIN/v-list-cron-jobs admin | grep 'v-update-sys-queue daily')" ]; then
+    echo "[ * ] Updating cron jobs..."
+    command="sudo $BIN/v-update-sys-queue daily"
+    $BIN/v-add-cron-job 'admin' '01' '00' '*' '*' '*' "$command"
+fi
+[ ! -f "touch $HESTIA/data/queue/daily.pipe" ] && touch $HESTIA/data/queue/daily.pipe
+
+# Remove existing network-up hooks so they get regenerated when updating the firewall
+# - network hook will also restore ipset config during start-up
+if [ -f "/usr/lib/networkd-dispatcher/routable.d/50-ifup-hooks" ]; then
+    rm "/usr/lib/networkd-dispatcher/routable.d/50-ifup-hooks"
+    $BIN/v-update-firewall
+fi
+if [ -f "/etc/network/if-pre-up.d/iptables" ];then
+    rm "/etc/network/if-pre-up.d/iptables"
+    $BIN/v-update-firewall
+fi
+
+# Add hestia-event.conf, if the server is running apache2
+if [ "$WEB_SYSTEM" = "apache2" ]; then
+    echo "[ * ] Updating Apache2 configuration..."
+    # Cleanup
+    rm --force /etc/apache2/mods-available/hestia-event.conf
+    rm --force /etc/apache2/mods-enabled/hestia-event.conf
+    rm --force /etc/apache2/conf-available/hestia-event.conf
+    rm --force /etc/apache2/conf-enabled/hestia-event.conf
+
+    if [ $(a2query -M) = 'event' ] && [ ! -e "/etc/apache2/conf.d/hestia-event.conf" ]; then
+        cp -f $HESTIA_INSTALL_DIR/apache2/hestia-event.conf /etc/apache2/conf.d/
+    fi
+
+    # Move apache mod_status config to /mods-available and rename it to prevent losing changes on upgrade
+    cp -f $HESTIA_INSTALL_DIR/apache2/status.conf /etc/apache2/mods-available/hestia-status.conf
+    cp -f /etc/apache2/mods-available/status.load /etc/apache2/mods-available/hestia-status.load
+    a2dismod --quiet status > /dev/null 2>&1
+    a2enmod --quiet hestia-status > /dev/null 2>&1
+    rm --force /etc/apache2/mods-enabled/status.conf # a2dismod will not remove the file if it isn't a symlink
+fi
+
+# Install File Manager during upgrade if environment variable oesn't already exist and isn't set to false
+# so that we don't override preference
+FILE_MANAGER_CHECK=$(cat $HESTIA/conf/hestia.conf | grep "FILE_MANAGER='false'")
+if [ -z "$FILE_MANAGER_CHECK" ]; then
+    if [ ! -e "$HESTIA/web/fm/configuration.php" ]; then
+        echo "[ ! ] Installing File Manager..."
+        # Install the File Manager
+        $HESTIA/bin/v-add-sys-filemanager quiet
+    else 
+        echo "[ * ] Updating File Manager configuration..."
+        # Update configuration.php
+        cp -f $HESTIA_INSTALL_DIR/filemanager/filegator/configuration.php $HESTIA/web/fm/configuration.php
+        # Set environment variable for interface
+        $HESTIA/bin/v-change-sys-config-value 'FILE_MANAGER' 'true'
+    fi
+fi
+
+# Enable nginx module loading
+if [ -f "/etc/nginx/nginx.conf" ]; then
+    echo "[ * ] Updating NGINX configuration..."
+    if [ ! -d "/etc/nginx/modules-enabled" ]; then
+        mkdir -p "/etc/nginx/modules-enabled"
+    fi
+
+    if ! grep --silent "include /etc/nginx/modules-enabled" /etc/nginx/nginx.conf; then
+        sed -i '/^pid/ a include /etc/nginx/modules-enabled/*.conf;' /etc/nginx/nginx.conf
+    fi
+fi
+
+# Fix public_(s)html group ownership
+echo "[ * ] Updating public_(s)html ownership..."
+for user in $($HESTIA/bin/v-list-sys-users plain); do
+    # skip users with missing home folder
+    [[ -d /home/${user}/ ]] || continue
+
+    # skip users without web domains
+    ls /home/${user}/web/*/public_*html >/dev/null 2>&1 || continue
+
+    chown --silent --no-dereference :www-data /home/$user/web/*/public_*html
+done
+
+# Fix phpMyAdmin blowfish_secret error message due to incorrect permissions
+if [ -e /var/lib/phpmyadmin/blowfish_secret.inc.php ]; then
+    echo "[ * ] Updating phpMyAdmin permissions..."
+    chmod 0644 /var/lib/phpmyadmin/blowfish_secret.inc.php
+fi
+
+# Ensure that backup compression level is correctly set
+GZIP_LVL_CHECK=$(cat $HESTIA/conf/hestia.conf | grep BACKUP_GZIP)
+if [ -z "$GZIP_LVL_CHECK" ]; then
+    echo "[ * ] Updating backup compression level variable..."
+    $BIN/v-change-sys-config-value "BACKUP_GZIP" '9'
+fi
+
+# Update phpMyAdmin/phpPgAdmin templates and set missing alias variables if necessary
+if [ -e "/var/lib/phpmyadmin" ]; then
+    PMA_ALIAS_CHECK=$(cat $HESTIA/conf/hestia.conf | grep DB_PMA_ALIAS)
+    if [ -z "$PMA_ALIAS_CHECK" ]; then
+        echo "[ * ] Updating phpMyAdmin alias..."
+        $HESTIA/bin/v-change-sys-db-alias "pma" "phpMyAdmin"
+    else
+        echo "[ * ] Updating phpMyAdmin configuration..."
+        $HESTIA/bin/v-change-sys-db-alias "pma" "$DB_PMA_ALIAS"
+    fi
+fi
+
+if [ -e "/var/lib/phppgadmin" ]; then
+    PGA_ALIAS_CHECK=$(cat $HESTIA/conf/hestia.conf | grep DB_PGA_ALIAS)
+    if [ -z "$PGA_ALIAS_CHECK" ]; then
+        echo "[ * ] Updating phpPgAdmin alias..."
+        $HESTIA/bin/v-change-sys-db-alias "pga" "phpPgAdmin"
+    else
+        echo "[ * ] Updating phpPgAdmin configuration..."
+        $HESTIA/bin/v-change-sys-db-alias "pga" "$DB_PGA_ALIAS"
+    fi
+fi
+
+# Ensure that backup compression level is correctly set
+GZIP_LVL_CHECK=$(cat $HESTIA/conf/hestia.conf | grep BACKUP_GZIP)
+if [ -z "$GZIP_LVL_CHECK" ]; then
+    echo "[ * ] Updating backup compression level variable..."
+    $BIN/v-change-sys-config-value "BACKUP_GZIP" '9'
+fi
+
+# Update template files to add warnings
+# Backup current templates
+cp -r -f $HESTIA/data/templates/* $HESTIA_BACKUP/templates/
+echo "[ ! ] Updating default web domain templates..."
+$BIN/v-update-web-templates
+echo "[ ! ] Updating default mail domain templates..."
+$BIN/v-update-mail-templates
+echo "[ ! ] Updating default DNS zone templates..."
+$BIN/v-update-dns-templates

+ 17 - 0
install/upgrade/versions/previous/1.2.1.sh

@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Hestia Control Panel upgrade script for target version 1.2.1
+
+#######################################################################################
+#######                      Place additional commands below.                   #######
+#######################################################################################
+
+# Update template files to add warnings
+# Backup current templates
+cp -r -f $HESTIA/data/templates/* $HESTIA_BACKUP/templates/
+echo "[ ! ] Updating default web domain templates..."
+$BIN/v-update-web-templates
+echo "[ ! ] Updating default mail domain templates..."
+$BIN/v-update-mail-templates
+echo "[ ! ] Updating default DNS zone templates..."
+$BIN/v-update-dns-templates

+ 1 - 1
src/deb/hestia/control

@@ -1,7 +1,7 @@
 Source: hestia
 Package: hestia
 Priority: optional
-Version: 1.2.0
+Version: 1.2.2
 Section: admin
 Maintainer: HestiaCP <info@hestiacp.com>
 Homepage: https://www.hestiacp.com

+ 3 - 2
src/deb/hestia/postinst

@@ -25,12 +25,13 @@ pma_v='5.0.2'
 #               Begin standard upgrade routines               #
 ###############################################################
 
-# Initialize backup directories
-upgrade_init_backup
 
 # Set up console display and welcome message
 upgrade_welcome_message
 
+# Initialize backup directories
+upgrade_init_backup
+
 # Execute version-specific upgrade scripts
 upgrade_start_routine