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

Merge pull request #2134 from hestiacp/staging/1.4.14

Release v1.4.14
Raphael Schneeberger 4 лет назад
Родитель
Сommit
d2d51533dd

+ 10 - 0
CHANGELOG.md

@@ -1,6 +1,16 @@
 # Changelog
 All notable changes to this project will be documented in this file.
 
+## [1.4.14] - Service release 
+
+### Bugfixes
+
+- Fixed an issue with edit package
+- Fixed an issue with v-update-letsencrypt and v-restart-service
+- Fixed an issue with v-add-sys-ip and Ubuntu with no netplan enabled
+- Fixed broken UPGRADE_MESSAGE variable not showing up in email
+- Include / expand the config backup system during update
+
 ## [1.4.13] - Service release 
 
 ### Features

+ 14 - 2
bin/v-add-sys-ip

@@ -76,8 +76,20 @@ if [ -z "$sys_ip_check" ]; then
     # Adding sys ip
     /sbin/ip addr add $ip/$cidr dev $iface \
         broadcast $broadcast label $iface
-
-    if dpkg-query -W -f'${Status}' "netplan*" 2>/dev/null | grep -q "ok installed"; then
+    
+    # Improve check netplan
+    if dpkg-query -W -f'${Status}' "netplan*" 2>/dev/null | grep -q "ok installed"; then 
+        result=$(cat /etc/netplan/*.yaml 2>/dev/null | grep $(hostname -I | cut -d' ' -f1));
+        if [ ! -z $result ]; then 
+            netplan=1
+        else
+            netplan=0
+        fi
+    else
+        netplan=0
+    fi
+    
+    if [ "$netplan" == "1" ]; then
         if [ -f "/etc/netplan/60-hestia.yaml" ]; then
             sys_ip="        - $ip/$cidr"
         else

+ 6 - 1
func/main.sh

@@ -1126,7 +1126,7 @@ is_format_valid() {
                 proxy_ext)      is_extention_format_valid "$arg" ;;
                 quota)          is_int_format_valid "$arg" 'quota' ;;
                 record)         is_common_format_valid "$arg" 'record';;
-                restart)        is_boolean_format_valid "$arg" 'restart' ;;
+                restart)        is_restart_format_valid "$arg" 'restart' ;;
                 role)           is_role_valid "$arg" 'role' ;;
                 rtype)          is_dns_type_format_valid "$arg" ;;
                 rule)           is_int_format_valid "$arg" "rule id" ;;
@@ -1188,6 +1188,11 @@ format_aliases() {
     fi
 }
 
+is_restart_format_valid() {
+  if [ "$1" != 'yes' ] && [ "$1" != 'no' ] && [ "$1" != 'ssl' ] && [ "$1" != 'reload' ];  then
+  check_result $E_INVALID "invalid $2 format :: $1"
+  fi
+}
 
 check_backup_conditions() {
     # Checking load average

+ 48 - 21
func/upgrade.sh

@@ -9,6 +9,15 @@ source $HESTIA/func/syshealth.sh
 #######                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() {
     if [[ "$new_version" =~ "alpha" ]] || [[ "$new_version" =~ "beta" ]]; then
         DEBUG_MODE="true"
@@ -193,11 +202,11 @@ upgrade_send_notification_to_email () {
         echo "" >> $message_tmp_file
 
         # 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 "The upgrade script has generated additional notifications, which must be heeded urgently:" >> $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
@@ -307,6 +316,15 @@ upgrade_init_backup() {
     if [ -e "/etc/ssh/sshd_config" ]; then
         mkdir -p $HESTIA_BACKUP/conf/ssh/
     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() {
@@ -355,36 +373,32 @@ upgrade_start_backup() {
         if [ "$DEBUG_MODE" = "true" ]; then
             echo "      ---- $WEB_SYSTEM"
         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
     if [ ! -z "$PROXY_SYSTEM" ]; then
         if [ "$DEBUG_MODE" = "true" ]; then
             echo "      ---- $PROXY_SYSTEM"
         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
     if [ ! -z "$IMAP_SYSTEM" ]; then
         if [ "$DEBUG_MODE" = "true" ]; then
             echo "      ---- $IMAP_SYSTEM"
         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
     if [ ! -z "$MAIL_SYSTEM" ]; then
         if [ "$DEBUG_MODE" = "true" ]; then
             echo "      ---- $MAIL_SYSTEM"
         fi
-        cp -f /etc/$MAIL_SYSTEM/*.conf $HESTIA_BACKUP/conf/$MAIL_SYSTEM/
+        cp -fr /etc/$MAIL_SYSTEM/* $HESTIA_BACKUP/conf/$MAIL_SYSTEM/
     fi
     if [ ! -z "$DNS_SYSTEM" ]; then
         if [ "$DNS_SYSTEM" = "bind9" ]; then
             if [ "$DEBUG_MODE" = "true" ]; then
                 echo "      ---- $DNS_SYSTEM"
             fi
-            cp -f /etc/bind/*.conf $HESTIA_BACKUP/conf/$DNS_SYSTEM/
+            cp -fr /etc/bind/* $HESTIA_BACKUP/conf/$DNS_SYSTEM/
         fi
     fi
     if [ ! -z "$DB_SYSTEM" ]; then
@@ -392,20 +406,14 @@ upgrade_start_backup() {
             if [ "$DEBUG_MODE" = "true" ]; then
                 echo "      ---- mysql"
             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
         if [[ "$DB_SYSTEM" =~ "pgsql" ]]; then
             if [ "$DEBUG_MODE" = "true" ]; then
                 echo "      ---- pgsql"
             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
     if [ ! -z "$FTP_SYSTEM" ]; then
@@ -431,8 +439,27 @@ upgrade_start_backup() {
         if [ "$DEBUG_MODE" = "true" ]; then
             echo "      ---- sshd"
         fi
-        cp -f /etc/ssh/sshd_config $HESTIA_BACKUP/conf/ssh/sshd_config
+        cp -f /etc/ssh/* $HESTIA_BACKUP/conf/ssh/
     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() {

+ 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.4.13'
+HESTIA_INSTALL_VER='1.4.14'
 pma_v='5.1.1'
 rc_v="1.4.11"
 multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0")

+ 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.4.13'
+HESTIA_INSTALL_VER='1.4.14'
 pma_v='5.1.1'
 rc_v="1.4.11"
 multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0")

+ 4 - 4
install/upgrade/upgrade.conf

@@ -21,7 +21,7 @@
 # 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_WEB_TEMPLATES='false'
 UPGRADE_UPDATE_MAIL_TEMPLATES='false'
 UPGRADE_UPDATE_DNS_TEMPLATES='false'
 
@@ -41,9 +41,9 @@ UPGRADE_UPDATE_FILEMANAGER='false'
 UPGRADE_UPDATE_FILEMANAGER_CONFIG='false'
 
 # 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                       #######

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

@@ -5,15 +5,14 @@
 #######################################################################################
 #######                      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
 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!"
-    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>."
 fi
 

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

@@ -0,0 +1,21 @@
+#!/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.                   #######
+#######################################################################################
+
+if [ -f "/etc/network/interfaces" ] && [ -f "/etc/netplan/60-hestia.yaml" ]; then
+    add_upgrade_message "Warning: Please check your network config!\n\nDuring this update a network compatibility issues has been detected. Both /etc/network/interfaces and /etc/netplan/60-hestia.yaml exists. This can lead to issues after a system reboot. Please review your network configuration."
+    $HESTIA/bin/v-add-user-notification admin "Invalid network configuration detected\n\nDuring this update a network compatibility issues has been detected. Both /etc/network/interfaces and /etc/netplan/60-hestia.yaml exists. This can lead to issues after a system reboot. Please review your network configuration."
+fi

+ 1 - 1
src/deb/hestia/control

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

+ 52 - 3
test/test.bats

@@ -1462,9 +1462,58 @@ function check_ip_not_banned(){
 @test "Test Whitelist Fail2ban" {
 
 echo   "1.2.3.4" >> $HESTIA/data/firewall/excludes.conf
-run v-add-firewall-ban '1.2.3.4' 'HESTIA'
-rm $HESTIA/data/firewall/excludes.conf
-check_ip_not_banned '1.2.3.4' 'HESTIA'
+  run v-add-firewall-ban '1.2.3.4' 'HESTIA'
+  rm $HESTIA/data/firewall/excludes.conf
+  check_ip_not_banned '1.2.3.4' 'HESTIA'
+}
+
+#----------------------------------------------------------#
+#                         PACKAGE                          #
+#----------------------------------------------------------#
+
+@test "Package: Create new Package" {
+    cp $HESTIA/data/packages/default.pkg /tmp/package
+    run v-add-user-package /tmp/package hestiatest
+    assert_success
+    refute_output
+}
+
+@test "Package: Assign user to new Package" {
+    run v-change-user-package  $user hestiatest
+    assert_success
+    refute_output
+}
+
+@test "Package: Create new package (Duplicate)" {
+    sed -i "s/BANDWIDTH='unlimited'/BANDWIDTH='100'/g" /tmp/package
+    run v-add-user-package /tmp/package hestiatest
+    assert_failure $E_EXISTS
+}
+
+@test "Package: Update new Package" {
+    sed -i "s/BANDWIDTH='unlimited'/BANDWIDTH='100'/g" /tmp/package
+    run v-add-user-package /tmp/package hestiatest yes
+    assert_success
+    refute_output
+}
+
+@test "Package: Update package of user" {
+    run v-change-user-package  $user hestiatest
+    assert_success
+    refute_output
+    run grep "BANDWIDTH='100'" $HESTIA/data/users/$user/user.conf
+    assert_success
+    assert_output --partial "100"
+}
+
+@test "Package: Delete package" {
+    run v-delete-user-package hestiatest
+    rm /tmp/package
+    assert_success
+    refute_output
+    run grep "BANDWIDTH='unlimited'" $HESTIA/data/users/$user/user.conf
+    assert_success
+    assert_output --partial "unlimited"
 }
 
 #----------------------------------------------------------#

+ 1 - 0
web/add/package/index.php

@@ -179,6 +179,7 @@ if (!empty($_POST['ok'])) {
         unset($output);
 
         fclose($fp);
+        unlink($tmpfile);
     }
 
     // Flush field values on success

+ 6 - 13
web/edit/package/index.php

@@ -233,11 +233,6 @@ if (!empty($_POST['save'])) {
     $v_time = escapeshellarg(date('H:i:s'));
     $v_date = escapeshellarg(date('Y-m-d'));
 
-    // Create temprorary directory
-    exec('mktemp -d', $output, $return_var);
-    $tmpdir = $output[0];
-    unset($output);
-
     // Save package file on a fs
     $pkg = "WEB_TEMPLATE=".$v_web_template."\n";
     $pkg .= "BACKEND_TEMPLATE=".$v_backend_template."\n";
@@ -258,18 +253,16 @@ if (!empty($_POST['save'])) {
     $pkg .= "BACKUPS=".$v_backups."\n";
     $pkg .= "TIME=".$v_time."\n";
     $pkg .= "DATE=".$v_date."\n";
-    $fp = fopen($tmpdir."/".$_POST['v_package'].".pkg", 'w');
-    fwrite($fp, $pkg);
-    fclose($fp);
 
-    // Save changes
-    exec(HESTIA_CMD."v-add-user-package ".$tmpdir." ".$v_package." 'yes'", $output, $return_var);
+    $tmpfile = tempnam('/tmp/', 'hst_');
+    $fp = fopen($tmpfile, 'w');
+    fwrite($fp, $pkg);
+    exec(HESTIA_CMD."v-add-user-package ".$tmpfile." ".$v_package." yes", $output, $return_var);
     check_return_code($return_var, $output);
     unset($output);
 
-    // Remove temporary dir
-    exec('rm -rf '.$tmpdir, $output, $return_var);
-    unset($output);
+    fclose($fp);
+    unlink($tmpfile);
 
     // Propogate new package
     exec(HESTIA_CMD."v-update-user-package ".$v_package." 'json'", $output, $return_var);