Explorar o código

Improve upgrade procedure (#2198)

* Improve upgrade procedure

1. Allow setting task on version 
Use upgrade_config_set_value Setting flag
2. Check version has changed instead of flag on dependencies

* Improve config var exsits

* Create /var/log/hestia/backup.log + chmod /backup/user.log
Jaap Marcus %!s(int64=4) %!d(string=hai) anos
pai
achega
6e2ac7ac14

+ 1 - 1
bin/v-add-sys-filemanager

@@ -105,7 +105,7 @@ fi
 # Add configuration file
 cp -f $HESTIA_INSTALL_DIR/filemanager/filegator/configuration.php $HESTIA/web/fm/configuration.php
 
-
+echo "$fm_v" > "${FM_INSTALL_DIR}/version"
 # Set permissions
 chown root: -R "${FM_INSTALL_DIR}"
 chown $user: "${FM_INSTALL_DIR}/private"

+ 3 - 1
bin/v-backup-user

@@ -770,6 +770,7 @@ echo "$backup_str" >> $USER_DATA/backup.conf
 tail -n $BACKUPS $USER_DATA/backup.conf > $USER_DATA/backup.conf_
 mv -f $USER_DATA/backup.conf_ $USER_DATA/backup.conf
 chmod 660 $USER_DATA/backup.conf
+chmod 660 $BACKUP/$user.log
 
 # Deleting task from queue
 sed -i "/v-backup-user $user /d" $HESTIA/data/queue/backup.pipe
@@ -783,10 +784,11 @@ if [ -e "$BACKUP/$user.log" ] && [ "$notify" = "yes" ]; then
     subj="$user → backup has been completed"
     email=$(get_user_value '$CONTACT')
     cat $BACKUP/$user.log |$SENDMAIL -s "$subj" "$email" "$notify"
-    rm $BACKUP/$user.log
     $BIN/v-add-user-notification "$user" "Backup created successfully" "<b>Archive:</b> $user.$backup_new_date.tar"
 fi
 
+
+
 # Logging
 $BIN/v-log-action "$user" "Info" "Backup" "Backup created (Archive: $backup_new_date.tar)."
 $BIN/v-log-action "system" "Info" "Backup" "Backup created (User: $user, Archive: $backup_new_date.tar)."

+ 59 - 50
func/syshealth.sh

@@ -171,18 +171,21 @@ function syshealth_restore_system_config() {
     fi
 }
 
+function check_key_exsits() {
+    grep -e "^$1=" $HESTIA/conf/hestia.conf 
+}
+
 # Repair System Configuration
 # Adds missing variables to $HESTIA/conf/hestia.conf with safe default values
 function syshealth_repair_system_config() {
     # Release branch
-    if [ -z "$RELEASE_BRANCH" ]; then
+    if  [[ -z $(check_key_exsits 'RELEASE_BRANCH') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: RELEASE_BRANCH ('release')"
         $BIN/v-change-sys-config-value 'RELEASE_BRANCH' 'release'
     fi
-
     # Webmail alias
     if [ -n "$IMAP_SYSTEM" ]; then
-        if [ -z "$WEBMAIL_ALIAS" ]; then
+        if [[ -z $(check_key_exsits 'WEBMAIL_ALIAS') ]]; then
             echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_ALIAS ('webmail')"
             $BIN/v-change-sys-config-value 'WEBMAIL_ALIAS' 'webmail'
         fi
@@ -191,13 +194,13 @@ function syshealth_repair_system_config() {
     # phpMyAdmin/phpPgAdmin alias
     if [ -n "$DB_SYSTEM" ]; then
         if [ "$DB_SYSTEM" = "mysql" ]; then
-            if [ -z "$DB_PMA_ALIAS" ]; then 
+            if [[ -z $(check_key_exsits 'DB_PMA_ALIAS') ]]; then 
                 echo "[ ! ] Adding missing variable to hestia.conf: DB_PMA_ALIAS ('phpmyadmin)"
                 $BIN/v-change-sys-config-value 'DB_PMA_ALIAS' 'phpmyadmin'
             fi
         fi
         if [ "$DB_SYSTEM" = "pgsql" ]; then
-            if [ -z "$DB_PGA_ALIAS" ]; then 
+            if [[ -z $(check_key_exsits 'DB_PGA_ALIAS') ]]; then 
                 echo "[ ! ] Adding missing variable to hestia.conf: DB_PGA_ALIAS ('phppgadmin')"
                 $BIN/v-change-sys-config-value 'DB_PGA_ALIAS' 'phppgadmin'
             fi
@@ -205,74 +208,74 @@ function syshealth_repair_system_config() {
     fi
 
     # Backup compression level
-    if [ -z "$BACKUP_GZIP" ]; then 
+    if [[ -z $(check_key_exsits 'BACKUP_GZIP') ]]; then 
         echo "[ ! ] Adding missing variable to hestia.conf: BACKUP_GZIP ('4')"
         $BIN/v-change-sys-config-value 'BACKUP_GZIP' '4'
     fi
 
     # Theme
-    if [ -z "$THEME" ]; then 
+    if [[ -z $(check_key_exsits 'THEME') ]]; then 
         echo "[ ! ] Adding missing variable to hestia.conf: THEME ('dark')"
         $BIN/v-change-sys-config-value 'THEME' 'dark'
     fi
 
     # Default language
-    if [ -z "$LANGUAGE" ]; then 
+    if [[ -z  $(check_key_exsits 'LANGUAGE') ]]; then 
         echo "[ ! ] Adding missing variable to hestia.conf: LANGUAGE ('en')"
-        $BIN/v-change-sys-language 'en'
+        $BIN/v-change-sys-language 'LANGUAGE' 'en'
     fi
 
     # Disk Quota
-    if [ -z "$DISK_QUOTA" ]; then 
+    if [[ -z $(check_key_exsits 'DISK_QUOTA') ]]; then 
         echo "[ ! ] Adding missing variable to hestia.conf: DISK_QUOTA ('no')"
         $BIN/v-change-sys-config-value 'DISK_QUOTA' 'no'
     fi
 
     # CRON daemon
-    if [ -z "$CRON_SYSTEM" ]; then 
+    if [[ -z $(check_key_exsits 'CRON_SYSTEM') ]]; then 
         echo "[ ! ] Adding missing variable to hestia.conf: CRON_SYSTEM ('cron')"
         $BIN/v-change-sys-config-value 'CRON_SYSTEM' 'cron'
     fi
 
     # Backend port
-    if [ -z "$BACKEND_PORT" ]; then 
+    if [[ -z $(check_key_exsits 'BACKEND_PORT') ]]; then 
         ORIGINAL_PORT=$(cat $HESTIA/nginx/conf/nginx.conf | grep "listen" | sed 's/[^0-9]*//g')
         echo "[ ! ] Adding missing variable to hestia.conf: BACKEND_PORT ('$ORIGINAL_PORT')"
         $HESTIA/bin/v-change-sys-config-value 'BACKEND_PORT' $PORT
     fi
 
     # Upgrade: Send email notification
-    if [ -z "$UPGRADE_SEND_EMAIL" ]; then 
+    if [[ -z $(check_key_exsits 'UPGRADE_SEND_EMAIL') ]]; then 
         echo "[ ! ] Adding missing variable to hestia.conf: UPGRADE_SEND_EMAIL ('true')"
         $BIN/v-change-sys-config-value 'UPGRADE_SEND_EMAIL' 'true'
     fi
 
     # Upgrade: Send email notification
-    if [ -z "$UPGRADE_SEND_EMAIL_LOG" ]; then 
+    if [[ -z $(check_key_exsits 'UPGRADE_SEND_EMAIL_LOG') ]]; then 
         echo "[ ! ] Adding missing variable to hestia.conf: UPGRADE_SEND_EMAIL_LOG ('false')"
         $BIN/v-change-sys-config-value 'UPGRADE_SEND_EMAIL_LOG' 'false'
     fi
 
     # File Manager
-    if [ -z "$FILE_MANAGER" ]; then
+    if [[ -z $(check_key_exsits 'FILE_MANAGER') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: FILE_MANAGER ('true')"
         $BIN/v-add-sys-filemanager quiet
     fi
     
     # Support for ZSTD / GZIP Change
-    if [ -z "$BACKUP_MODE" ]; then
+    if [[ -z $(check_key_exsits 'BACKUP_MODE') ]]; then
         echo "[ ! ] Setting zstd backup compression type as default..."
         $BIN/v-change-sys-config-value "BACKUP_MODE" "zstd"
     fi
     
     # Login style switcher
-    if [ -z "$LOGIN_STYLE" ]; then
+    if [[ -z $(check_key_exsits 'LOGIN_STYLE') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: LOGIN_STYLE ('default')"
         $BIN/v-change-sys-config-value "LOGIN_STYLE" "default"
     fi
     
     # Webmail clients
-    if [ -z "$WEBMAIL_SYSTEM" ]; then
+    if [[ -z $(check_key_exsits 'WEBMAIL_SYSTEM') ]]; then
         if [ -d "/var/lib/roundcube" ]; then 
             echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_SYSTEM ('roundcube')"
             $BIN/v-change-sys-config-value "WEBMAIL_SYSTEM" "roundcube"
@@ -283,22 +286,27 @@ function syshealth_repair_system_config() {
     fi
 
     # Inactive session timeout
-    if [ -z "$INACTIVE_SESSION_TIMEOUT" ]; then
+    if [[ -z $(check_key_exsits 'INACTIVE_SESSION_TIMEOUT') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: INACTIVE_SESSION_TIMEOUT ('60')"
         $BIN/v-change-sys-config-value "INACTIVE_SESSION_TIMEOUT" "60"
     fi
 
     # Enforce subdomain ownership
-    if [ -z "$ENFORCE_SUBDOMAIN_OWNERSHIP" ]; then
+    if [[ -z $(check_key_exsits 'ENFORCE_SUBDOMAIN_OWNERSHIP') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: ENFORCE_SUBDOMAIN_OWNERSHIP ('no')"
         $BIN/v-change-sys-config-value "ENFORCE_SUBDOMAIN_OWNERSHIP" "no"
     fi
-
+    
+    if [[ -z $(check_key_exsits 'API') ]]; then 
+        echo "[ ! ] Adding missing variable to hestia.conf: API ('no')"   
+        $BIN/v-change-sys-config-value "API" "no"
+    fi
+    
     # API access allowed IP's
     if [ "$API" = "yes" ]; then
         check_api_key=$(grep "API_ALLOWED_IP" $HESTIA/conf/hestia.conf)
         if [ -z "$check_api_key" ]; then
-            if [ -z "$API_ALLOWED_IP" ]; then
+            if [[ -z $(check_key_exsits 'API_ALLOWED_IP') ]]; then
                 echo "[ ! ] Adding missing variable to hestia.conf: API_ALLOWED_IP ('allow-all')"        
                 $BIN/v-change-sys-config-value "API_ALLOWED_IP" "allow-all"
             fi
@@ -306,116 +314,117 @@ function syshealth_repair_system_config() {
     fi
     
     # Enforce subdomain ownership
-    if [ -z "$ENFORCE_SUBDOMAIN_OWNERSHIP" ]; then
+    if [[ -z $(check_key_exsits 'ENFORCE_SUBDOMAIN_OWNERSHIP') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: ENFORCE_SUBDOMAIN_OWNERSHIP ('yes')"
         $BIN/v-change-sys-config-value "ENFORCE_SUBDOMAIN_OWNERSHIP" "yes"
     fi
     # Debug mode
-    if [ -z "$DEBUG_MODE" ]; then
+    if [[ -z $(check_key_exsits 'DEBUG_MODE') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: DEBUG_MODE ('false')"
         $BIN/v-change-sys-config-value "DEBUG_MODE" "false"
     fi
     # Quick install plugin
-    if [ -z "$PLUGIN_APP_INSTALLER" ]; then
+    if [[ -z $(check_key_exsits 'PLUGIN_APP_INSTALLER') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: PLUGIN_APP_INSTALLER ('true')"
         $BIN/v-change-sys-config-value "PLUGIN_APP_INSTALLER" "true"
     fi
     # Enable preview mode
-    if [ -z "$POLICY_SYSTEM_ENABLE_BACON" ]; then
+    if [[ -z $(check_key_exsits 'POLICY_SYSTEM_ENABLE_BACON') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: POLICY_SYSTEM_ENABLE_BACON ('false')"
         $BIN/v-change-sys-config-value "POLICY_SYSTEM_ENABLE_BACON" "false"
     fi
     # Hide system services
-    if [ -z "$POLICY_SYSTEM_HIDE_SERVICES" ]; then
+    if [[ -z $(check_key_exsits 'POLICY_SYSTEM_HIDE_SERVICES') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: POLICY_SYSTEM_HIDE_SERVICES ('no')"
         $BIN/v-change-sys-config-value "POLICY_SYSTEM_HIDE_SERVICES" "no"
     fi
     # Password reset
-    if [ -z "$POLICY_SYSTEM_PASSWORD_RESET" ]; then
+    if [[ -z $(check_key_exsits 'POLICY_SYSTEM_PASSWORD_RESET') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: POLICY_SYSTEM_PASSWORD_RESET ('no')"
         $BIN/v-change-sys-config-value "POLICY_SYSTEM_PASSWORD_RESET" "no"
     fi
-    # Protect admin user
-    if [ -z "$POLICY_SYSTEM_PROTECTED_ADMIN" ]; then
-        echo "[ ! ] Adding missing variable to hestia.conf: POLICY_SYSTEM_PROTECTED_ADMIN ('no')"
-        $BIN/v-change-sys-config-value "POLICY_SYSTEM_PROTECTED_ADMIN" "no"
-    fi
+
     # Theme editor
-    if [ -z "$POLICY_USER_CHANGE_THEME" ]; then
+    if [[ -z $(check_key_exsits 'POLICY_USER_CHANGE_THEME') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_CHANGE_THEME ('yes')"
         $BIN/v-change-sys-config-value "POLICY_USER_CHANGE_THEME" "true"
     fi    
+    # Protect admin user
+    if [[ -z $(check_key_exsits 'POLICY_SYSTEM_PROTECTED_ADMIN') ]]; then
+        echo "[ ! ] Adding missing variable to hestia.conf: POLICY_SYSTEM_PROTECTED_ADMIN ('no')"
+        $BIN/v-change-sys-config-value "POLICY_SYSTEM_PROTECTED_ADMIN" "no"
+    fi  
     # Allow user delete logs
-    if [ -z "$POLICY_USER_DELETE_LOGS" ]; then
+    if [[ -z $(check_key_exsits 'POLICY_USER_DELETE_LOGS') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_DELETE_LOGS ('yes')"
         $BIN/v-change-sys-config-value "POLICY_USER_DELETE_LOGS" "yes"
     fi
     # Allow users to delete details
-    if [ -z "$POLICY_USER_EDIT_DETAILS" ]; then
+    if [[ -z $(check_key_exsits 'POLICY_USER_EDIT_DETAILS') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_EDIT_DETAILS ('yes')"
         $BIN/v-change-sys-config-value "POLICY_USER_EDIT_DETAILS" "yes"
     fi
     # Allow users to edit DNS templates
-    if [ -z "$POLICY_USER_EDIT_DNS_TEMPLATES" ]; then
+    if [[ -z $(check_key_exsits 'POLICY_USER_EDIT_DNS_TEMPLATES') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_EDIT_DNS_TEMPLATES ('yes')"
         $BIN/v-change-sys-config-value "POLICY_USER_EDIT_DNS_TEMPLATES" "yes"
     fi
     # Allow users to edit web templates
-    if [ -z "$POLICY_USER_EDIT_WEB_TEMPLATES" ]; then
+    if [[ -z $(check_key_exsits 'POLICY_USER_EDIT_WEB_TEMPLATES') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_EDIT_WEB_TEMPLATES ('yes')"
         $BIN/v-change-sys-config-value "POLICY_USER_EDIT_WEB_TEMPLATES" "true"
     fi
     # View user logs
-    if [ -z "$POLICY_USER_VIEW_LOGS" ]; then
+    if [[ -z $(check_key_exsits 'POLICY_USER_VIEW_LOGS') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_VIEW_LOGS ('yes')"
         $BIN/v-change-sys-config-value "POLICY_USER_VIEW_LOGS" "true"
     fi
     # Allow users to login (read only) when suspended
-    if [ -z "$POLICY_USER_VIEW_SUSPENDED" ]; then
+    if [[ -z $(check_key_exsits 'POLICY_USER_VIEW_SUSPENDED') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: POLICY_USER_VIEW_SUSPENDED ('no')"
         $BIN/v-change-sys-config-value "POLICY_USER_VIEW_SUSPENDED" "no"
     fi
     # PHPMyadmin SSO key
-    if [ -z "$PHPMYADMIN_KEY" ]; then
+    if [[ -z $(check_key_exsits 'PHPMYADMIN_KEY') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: PHPMYADMIN_KEY ('')"
         $BIN/v-change-sys-config-value "PHPMYADMIN_KEY" ""
     fi
     # Use SMTP server for hestia internal mail 
-    if [ -z "$USE_SERVER_SMTP" ]; then
+    if [[ -z $(check_key_exsits 'USE_SERVER_SMTP') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: USE_SERVER_SMTP ('')"
         $BIN/v-change-sys-config-value "USE_SERVER_SMTP" "false"
     fi
 
-    if [ -z "$SERVER_SMTP_PORT" ]; then
+    if [[ -z $(check_key_exsits 'SERVER_SMTP_HOST') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: SERVER_SMTP_PORT ('')"
-        $BIN/v-change-sys-config-value "SERVER_SMTP_PORT" ""
+        $BIN/v-change-sys-config-value "SERVER_SMTP_HOST" ""
     fi
 
-    if [ -z "$SERVER_SMTP_HOST" ]; then
+    if [[ -z $(check_key_exsits 'SERVER_SMTP_HOST') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: SERVER_SMTP_HOST ('')"
         $BIN/v-change-sys-config-value "SERVER_SMTP_HOST" ""
     fi
 
-    if [ -z "$SERVER_SMTP_SECURITY" ]; then
+    if [[ -z $(check_key_exsits 'SERVER_SMTP_SECURITY') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: SERVER_SMTP_SECURITY ('')"
         $BIN/v-change-sys-config-value "SERVER_SMTP_SECURITY" ""
     fi
 
-    if [ -z "$SERVER_SMTP_USER" ]; then
+    if [[ -z $(check_key_exsits 'SERVER_SMTP_USER') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: SERVER_SMTP_USER ('')"
         $BIN/v-change-sys-config-value "SERVER_SMTP_USER" ""
     fi
     
-    if [ -z "$SERVER_SMTP_PASSWD" ]; then
+    if [[ -z $(check_key_exsits 'SERVER_SMTP_PASSWD') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: SERVER_SMTP_PASSWD ('')"
         $BIN/v-change-sys-config-value "SERVER_SMTP_PASSWD" ""
     fi
         
-    if [ -z "$SERVER_SMTP_ADDR" ]; then
+    if [[ -z $(check_key_exsits 'SERVER_SMTP_ADDR') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: SERVER_SMTP_ADDR ('')"
         $BIN/v-change-sys-config-value "SERVER_SMTP_ADDR" ""
     fi    
-    if [ -z "$POLICY_CSRF_STRICTNESS" ]; then
+    if [[ -z $(check_key_exsits 'POLICY_CSRF_STRICTNESS') ]]; then
         echo "[ ! ] Adding missing variable to hestia.conf: POLICY_CSRF_STRICTNESS ('')"
         $BIN/v-change-sys-config-value "POLICY_CSRF_STRICTNESS" "1"
     fi  

+ 106 - 81
func/upgrade.sh

@@ -3,6 +3,7 @@
 # Hestia Control Panel - Upgrade Control Script
 
 # Import system health check and repair library
+# shellcheck source=/usr/local/hestia/func/syshealth.sh
 source $HESTIA/func/syshealth.sh
 
 #####################################################################
@@ -237,6 +238,29 @@ upgrade_send_log_to_email() {
     fi
 }
 
+upgrade_config_set_value() {
+    if [ -f "$HESTIA_BACKUP/upgrade.conf" ]; then 
+        if [ "$2" = "true" ]; then 
+            sed -i "s/$1='false'/$1='true'/g" $HESTIA_BACKUP/upgrade.conf
+        fi
+    fi
+}
+
+prepare_upgrade_config () {
+    mkdir -p $HESTIA_BACKUP
+    touch $HESTIA_BACKUP/upgrade.conf
+    while IFS='= ' read -r lhs rhs
+      do
+          if [[ ! $lhs =~ ^\ *# && -n $lhs ]]; then
+              rhs="${rhs%%\#*}"    # Del in line right comments
+              rhs="${rhs%%*( )}"   # Del trailing spaces
+              rhs="${rhs%\'*}"     # Del opening string quotes 
+              rhs="${rhs#\'*}"     # Del closing string quotes 
+              echo "$lhs='$rhs'" >> $HESTIA_BACKUP/upgrade.conf
+          fi
+      done < "$HESTIA/install/upgrade/upgrade.conf"
+}
+
 upgrade_init_backup() {
     # Ensure that backup directories are created
     # Hestia Control Panel configuration files
@@ -464,7 +488,6 @@ upgrade_start_backup() {
 
 upgrade_refresh_config() {
     source_conf "/usr/local/hestia/conf/hestia.conf"
-    source /usr/local/hestia/func/main.sh
 }
 
 upgrade_start_routine() {   
@@ -517,111 +540,111 @@ upgrade_start_routine() {
 }
 
 upgrade_phpmyadmin() {
-    if [ "$UPGRADE_UPDATE_PHPMYADMIN" = "true" ]; then
-        # Check if MariaDB/MySQL is installed on the server before attempting to install or upgrade phpMyAdmin
-        if [ -n "$(echo $DB_SYSTEM | grep -w 'mysql')" ]; then
-            # Define version check function
-            function version_ge(){ test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" -o -n "$1" -a "$1" = "$2"; }
-
-            pma_release_file=$(ls /usr/share/phpmyadmin/RELEASE-DATE-* 2>/dev/null |tail -n 1)
-            if version_ge "${pma_release_file##*-}" "$pma_v"; then
-                echo "[ ! ] Verifying phpMyAdmin v${pma_release_file##*-} installation..."
-                # Update permissions
-                if [ -e /var/lib/phpmyadmin/blowfish_secret.inc.php ]; then
-                    chown root:www-data /var/lib/phpmyadmin/blowfish_secret.inc.php
-                    chmod 0640 /var/lib/phpmyadmin/blowfish_secret.inc.php
-                fi
-            else
-                # Display upgrade information
-                echo "[ * ] Upgrading phpMyAdmin to version v$pma_v..."
-                [ -d /usr/share/phpmyadmin ] || mkdir -p /usr/share/phpmyadmin
-
-                # Download latest phpMyAdmin release
-                wget --quiet https://files.phpmyadmin.net/phpMyAdmin/$pma_v/phpMyAdmin-$pma_v-all-languages.tar.gz
+    # Check if MariaDB/MySQL is installed on the server before attempting to install or upgrade phpMyAdmin
+    if [ -n "$(echo $DB_SYSTEM | grep -w 'mysql')" ]; then
+        # Define version check function
+        function version_ge(){ test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" -o -n "$1" -a "$1" = "$2"; }
+
+        pma_release_file=$(ls /usr/share/phpmyadmin/RELEASE-DATE-* 2>/dev/null |tail -n 1)
+        if version_ge "${pma_release_file##*-}" "$pma_v"; then
+            echo "[ ! ] Verifying phpMyAdmin v${pma_release_file##*-} installation..., No update found"
+            # Update permissions
+            if [ -e /var/lib/phpmyadmin/blowfish_secret.inc.php ]; then
+                chown root:www-data /var/lib/phpmyadmin/blowfish_secret.inc.php
+                chmod 0640 /var/lib/phpmyadmin/blowfish_secret.inc.php
+            fi
+        else
+            # Display upgrade information
+            echo "[ * ] Upgrading phpMyAdmin to version v$pma_v..."
+            [ -d /usr/share/phpmyadmin ] || mkdir -p /usr/share/phpmyadmin
 
-                # Unpack files
-                tar xzf phpMyAdmin-$pma_v-all-languages.tar.gz
+            # Download latest phpMyAdmin release
+            wget --quiet https://files.phpmyadmin.net/phpMyAdmin/$pma_v/phpMyAdmin-$pma_v-all-languages.tar.gz
 
-                # Delete file to prevent error
-                rm -rf /usr/share/phpmyadmin/doc/html
+            # Unpack files
+            tar xzf phpMyAdmin-$pma_v-all-languages.tar.gz
 
-                # Overwrite old files
-                cp -rf phpMyAdmin-$pma_v-all-languages/* /usr/share/phpmyadmin
+            # Delete file to prevent error
+            rm -rf /usr/share/phpmyadmin/doc/html
 
-                # Set config and log directory
-                sed -i "s|define('CONFIG_DIR', ROOT_PATH);|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
-                sed -i "s|define('TEMP_DIR', ROOT_PATH . 'tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
+            # Overwrite old files
+            cp -rf phpMyAdmin-$pma_v-all-languages/* /usr/share/phpmyadmin
 
-                # Create temporary folder and change permissions
-                if [ ! -d /usr/share/phpmyadmin/tmp ]; then
-                    mkdir /usr/share/phpmyadmin/tmp
-                    chown root:www-data /usr/share/phpmyadmin/tmp
-                    chmod 770 /usr/share/phpmyadmin/tmp
-                    
-                fi
+            # Set config and log directory
+            sed -i "s|define('CONFIG_DIR', ROOT_PATH);|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
+            sed -i "s|define('TEMP_DIR', ROOT_PATH . 'tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
 
-                if [ -e /var/lib/phpmyadmin/blowfish_secret.inc.php ]; then
-                    chown root:www-data /var/lib/phpmyadmin/blowfish_secret.inc.php
-                    chmod 0640 /var/lib/phpmyadmin/blowfish_secret.inc.php
-                fi
+            # Create temporary folder and change permissions
+            if [ ! -d /usr/share/phpmyadmin/tmp ]; then
+                mkdir /usr/share/phpmyadmin/tmp
+                chown root:www-data /usr/share/phpmyadmin/tmp
+                chmod 770 /usr/share/phpmyadmin/tmp
+                
+            fi
 
-                # Clean up source files
-                rm -fr phpMyAdmin-$pma_v-all-languages
-                rm -f phpMyAdmin-$pma_v-all-languages.tar.gz
+            if [ -e /var/lib/phpmyadmin/blowfish_secret.inc.php ]; then
+                chown root:www-data /var/lib/phpmyadmin/blowfish_secret.inc.php
+                chmod 0640 /var/lib/phpmyadmin/blowfish_secret.inc.php
             fi
+
+            # Clean up source files
+            rm -fr phpMyAdmin-$pma_v-all-languages
+            rm -f phpMyAdmin-$pma_v-all-languages.tar.gz
         fi
     fi
 }
 
 upgrade_filemanager() {
-    if [ "$UPGRADE_UPDATE_FILEMANAGER" = "true" ]; then
-        FILE_MANAGER_CHECK=$(cat $HESTIA/conf/hestia.conf | grep "FILE_MANAGER='false'")
-        if [ -z "$FILE_MANAGER_CHECK" ]; then
+    FILE_MANAGER_CHECK=$(cat $HESTIA/conf/hestia.conf | grep "FILE_MANAGER='false'")
+    if [ -z "$FILE_MANAGER_CHECK" ]; then
+        if [ -f "$HESTIA/web/fm/version" ]; then 
+        fm_verison=$(cat $HESTIA/web/fm/version);
+        else
+        fm_verison="1.0.0"
+        fi
+        if [ "$fm_verison" != "$fm_v" ]; then 
             echo "[ * ] Updating File Manager..."
             # Reinstall the File Manager
             $HESTIA/bin/v-delete-sys-filemanager quiet
             $HESTIA/bin/v-add-sys-filemanager quiet
-        fi
-    fi
-}
-
-upgrade_filemanager_update_config() {
-    if [ "$UPGRADE_UPDATE_FILEMANAGER_CONFIG" = "true" ]; then
-        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 "[ * ] 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'
+        else
+            echo "[ * ] Verify version Filemanager, No update found"
+            
+            if [ "$UPGRADE_UPDATE_FILEMANAGER_CONFIG" = "true" ]; then
+                if [ -e "$HESTIA/web/fm/configuration.php" ]; then
+                    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
         fi
-    fi
+    fi  
 }
 
 upgrade_roundcube(){
-    if [ "$UPGRADE_UPDATE_ROUNDCUBE" = "true" ]; then
-        if [ -n "$(echo "$WEBMAIL_SYSTEM" | grep -w 'roundcube')" ]; then
-            rc_version=$(cat /var/lib/roundcube/index.php | grep -o -E '[0-9].[0-9].[0-9]+' | head -1);
-            if [ "$rc_version" != "$rc_v" ]; then
-                echo "[ * ] Upgrading Roundcube to version v$rc_v..."
-                $HESTIA/bin/v-add-sys-roundcube
-            fi
+    if [ -n "$(echo "$WEBMAIL_SYSTEM" | grep -w 'roundcube')" ]; then
+        rc_version=$(cat /var/lib/roundcube/index.php | grep -o -E '[0-9].[0-9].[0-9]+' | head -1);
+        if [ "$rc_version" != "$rc_v" ]; then
+            echo "[ * ] Upgrading Roundcube to version v$rc_v..."
+            $HESTIA/bin/v-add-sys-roundcube
+        else
+            echo "[ * ] Verify version Roundcube, No update found"
         fi
     fi
 }
 
 upgrade_rainloop(){
-    if [ "$UPGRADE_UPDATE_RAINLOOP" = "true" ]; then
-        if [ -n "$(echo "$WEBMAIL_SYSTEM" | grep -w 'rainloop')" ]; then
-            rc_version=$(cat /var/lib/rainloop/data/VERSION);
-            if [ "$rc_version" != "$rl_v" ]; then
-                echo "[ * ] Upgrading Rainloop to version v$rl_v..."
-                $HESTIA/bin/v-add-sys-rainloop
-            fi
+    if [ -n "$(echo "$WEBMAIL_SYSTEM" | grep -w 'rainloop')" ]; then
+        rl_version=$(cat /var/lib/rainloop/data/VERSION);
+        if [ "$rl_version" != "$rl_v" ]; then
+            echo "[ * ] Upgrading Rainloop to version v$rl_v..."
+            $HESTIA/bin/v-add-sys-rainloop
+        else
+            echo "[ * ] Verify version Rainloop, No update found"
+        fi
         fi
-    fi
 }
 
 upgrade_phpmailer(){
@@ -631,9 +654,11 @@ upgrade_phpmailer(){
     fi
     phpm_version=$(cat $HESTIA/web/inc/vendor/phpmailer/phpmailer/VERSION);
     if [ "$phpm_version" != "$pm_v" ]; then
-    echo "[ * ] Upgrading Rainloop to version v$pm_v..."
+    echo "[ * ] Upgrade phpmailer"
         $HESTIA/bin/v-add-sys-phpmailer
-    fi
+    else
+        echo "[ * ] Verify Version phpmailer No update found"
+    fi 
 }
 
 upgrade_rebuild_web_templates() {
@@ -743,7 +768,7 @@ upgrade_restart_services() {
             fi
             $BIN/v-restart-dns 'yes'
         fi
-        versions_list=$(ls -d /etc/php/*)
+        versions_list=$($BIN/v-list-sys-php plain)
         for v in $versions_list; do 
             if [ "$DEBUG_MODE" = "true" ]; then
                 echo "      - php$v-fpm"

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

@@ -1069,7 +1069,7 @@ mkdir -p $HESTIA/conf $HESTIA/ssl $HESTIA/data/ips \
 touch $HESTIA/data/queue/backup.pipe $HESTIA/data/queue/disk.pipe \
     $HESTIA/data/queue/webstats.pipe $HESTIA/data/queue/restart.pipe \
     $HESTIA/data/queue/traffic.pipe $HESTIA/data/queue/daily.pipe $HESTIA/log/system.log \
-    $HESTIA/log/nginx-error.log $HESTIA/log/auth.log
+    $HESTIA/log/nginx-error.log $HESTIA/log/auth.log $HESTIA/log/backup.log
 chmod 750 $HESTIA/conf $HESTIA/data/users $HESTIA/data/ips $HESTIA/log
 chmod -R 750 $HESTIA/data/queue
 chmod 660 /var/log/hestia/*

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

@@ -1106,7 +1106,7 @@ mkdir -p $HESTIA/conf $HESTIA/ssl $HESTIA/data/ips \
 touch $HESTIA/data/queue/backup.pipe $HESTIA/data/queue/disk.pipe \
     $HESTIA/data/queue/webstats.pipe $HESTIA/data/queue/restart.pipe \
     $HESTIA/data/queue/traffic.pipe $HESTIA/data/queue/daily.pipe $HESTIA/log/system.log \
-    $HESTIA/log/nginx-error.log $HESTIA/log/auth.log
+    $HESTIA/log/nginx-error.log $HESTIA/log/auth.log $HESTIA/log/backup.log
 chmod 750 $HESTIA/conf $HESTIA/data/users $HESTIA/data/ips $HESTIA/log
 chmod -R 750 $HESTIA/data/queue
 chmod 660 /var/log/hestia/*

+ 9 - 19
install/upgrade/upgrade.conf

@@ -21,34 +21,20 @@
 # Update default templates when performing an upgrade
 # 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.
-UPGRADE_UPDATE_WEB_TEMPLATES='true'
-UPGRADE_UPDATE_MAIL_TEMPLATES='true'
-UPGRADE_UPDATE_DNS_TEMPLATES='true'
-
-# Update phpMyAdmin to the latest version during upgrade
-UPGRADE_UPDATE_PHPMYADMIN='true'
-
-# Update roundcube to the latest version during upgrade
-UPGRADE_UPDATE_ROUNDCUBE='true'
-
-# Update rainloop to the latest version during upgrade
-UPGRADE_UPDATE_RAINLOOP='true'
-
-# Update the File Manager or it's configuration file
-# UPGRADE_UPDATE_FILEMANAGER: Performs an upgrade/repair install of the File Manager
-# UPGRADE_UPDATE_FILEMANAGER_CONFIG: Updates only the configuration file
-UPGRADE_UPDATE_FILEMANAGER='true'
-UPGRADE_UPDATE_FILEMANAGER_CONFIG='true'
+UPGRADE_UPDATE_WEB_TEMPLATES='false'
+UPGRADE_UPDATE_MAIL_TEMPLATES='false'
+UPGRADE_UPDATE_DNS_TEMPLATES='false'
 
 # Post installation clean-up
 UPGRADE_REPLACE_KNOWN_KEYS='true'
-UPGRADE_REBUILD_USERS='true'
+UPGRADE_REBUILD_USERS='false'
 UPGRADE_RESTART_SERVICES='true'
 
 #######################################################################################
 #######                        3rd Party Software Updates                       #######
 #######################################################################################
 
+# Check if update is required by matching versions if version != current version run update 
 # Set version of phpMyAdmin to install during upgrade if not already installed
 pma_v='5.1.1'
 
@@ -59,6 +45,10 @@ rc_v='1.5.0'
 # Set version of Rainloop (Webmail) to update during upgrade if not already installed
 rl_v='1.16.0'
 
+# Update the File Manager or it's configuration file
+# Check if Filegator requires an update based on current version and setting below 
+# UPGRADE_UPDATE_FILEMANAGER_CONFIG: Updates only the configuration file if changes are made but now new issue has been issued!
+UPGRADE_UPDATE_FILEMANAGER_CONFIG='false'
 # Set version of File manager to update during upgrade if not already installed
 fm_v='7.7.0'
 

+ 6 - 2
src/deb/hestia/postinst

@@ -16,7 +16,6 @@ source $HESTIA/func/upgrade.sh
 # shellcheck source=/usr/local/hestia/func/main.sh
 source $HESTIA/func/main.sh
 source_conf "$HESTIA/conf/hestia.conf"
-source $HESTIA/install/upgrade/upgrade.conf
 
 ###############################################################
 #             Set new version numbers for packages            #
@@ -34,6 +33,9 @@ is_debug_build
 # Detect operating system version
 detect_os
 
+# Initialize upgrade
+prepare_upgrade_config
+
 # Initialize backup directories
 upgrade_init_backup
 
@@ -60,9 +62,11 @@ upgrade_start_backup | tee -a $LOG
 # Execute version-specific upgrade scripts
 upgrade_start_routine | tee -a $LOG
 
+# Run upgrades of dependencies
+source_conf "$HESTIA_BACKUP/upgrade.conf"
+
 # Upgrade File Manager and update configuration
 upgrade_filemanager | tee -a $LOG
-upgrade_filemanager_update_config | tee -a $LOG
 
 # Update Web domain templates
 upgrade_rebuild_web_templates | tee -a $LOG