Explorar o código

Fix issues with config not loading correctly

Jaap Marcus %!s(int64=5) %!d(string=hai) anos
pai
achega
a27a9cb702
Modificáronse 3 ficheiros con 47 adicións e 15 borrados
  1. 12 5
      bin/v-add-web-domain-redirect
  2. 12 6
      bin/v-delete-web-domain-redirect
  3. 23 4
      web/edit/web/index.php

+ 12 - 5
bin/v-add-web-domain-redirect

@@ -1,6 +1,6 @@
 #!/bin/bash
 # info: Adding force redirect to domain
-# options: USER DOMAIN REDIRECT HTTPCODE
+# options: USER DOMAIN REDIRECT HTTPCODE [RESTART]
 # labels: hestia web
 #
 # example: v-add-web-domain-redirect user domain.tld domain.tld 
@@ -22,6 +22,7 @@ user=$1
 domain=$2
 redirect=$(echo $3 | idn);
 code=${4-301}
+restart=${5-no}
 
 # Includes
 source $HESTIA/func/main.sh
@@ -31,7 +32,7 @@ source $HESTIA/conf/hestia.conf
 #                    Verifications                         #
 #----------------------------------------------------------#
 
-check_args '3' "$#" 'USER DOMAIN REDIRECT [HTTP-CODE]'
+check_args '3' "$#" 'USER DOMAIN REDIRECT [HTTP-CODE] [RESTART]'
 is_format_valid 'user' 'domain'
 is_number_format_valid "$code" "code"
 is_object_valid 'user' 'USER' "$user"
@@ -101,9 +102,15 @@ fi
 
 update_object_value 'web' 'DOMAIN' "$domain" '$REDIRECT' "$redirect"
 update_object_value 'web' 'DOMAIN' "$domain" '$REDIRECT_CODE' "$code"
-# Restart web server
-$BIN/v-restart-web
-check_result $? "Web restart failed" > /dev/null
+
+if [ "$restart" = "yes" ]; then
+    # Restarting web server
+    $BIN/v-restart-web $restart
+    check_result $? "Web restart failed" >/dev/null
+    
+    $BIN/v-restart-proxy $restart
+    check_result $? "Proxy restart failed" >/dev/null
+fi
 
 # Logging
 log_history "Enable forced redirect $domain"

+ 12 - 6
bin/v-delete-web-domain-redirect

@@ -1,6 +1,6 @@
 #!/bin/bash
 # info: Delete force redirect to domain
-# options: USER DOMAIN
+# options: USER DOMAIN [RESTART]
 # labels: hestia web
 #
 # example: v-add-web-domain-redirect user domain.tld
@@ -15,7 +15,7 @@
 # Argument definition
 user=$1
 domain=$2
-redirect=$3
+restart=${3-no}
 
 
 # Includes
@@ -27,7 +27,7 @@ source $HESTIA/conf/hestia.conf
 #                    Verifications                         #
 #----------------------------------------------------------#
 
-check_args '2' "$#" 'USER DOMAIN'
+check_args '2' "$#" 'USER DOMAIN [RESTART]'
 is_format_valid 'user' 'domain'
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
@@ -59,9 +59,15 @@ fi
 
 update_object_value 'web' 'DOMAIN' "$domain" '$REDIRECT' ""
 update_object_value 'web' 'DOMAIN' "$domain" '$REDIRECT_CODE' ""
-# Restart web server
-$BIN/v-restart-web
-check_result $? "Web restart failed" > /dev/null
+
+if [ "$restart" = "yes" ]; then
+    # Restarting web server
+    $BIN/v-restart-web $restart
+    check_result $? "Web restart failed" >/dev/null
+    
+    $BIN/v-restart-proxy $restart
+    check_result $? "Proxy restart failed" >/dev/null
+fi
 
 # Logging
 log_history "Enable forced redirect $domain"

+ 23 - 4
web/edit/web/index.php

@@ -573,6 +573,8 @@ if (!empty($_POST['save'])) {
         check_return_code($return_var,$output);
         unset($output);
         $v_ssl_forcessl = 'yes';
+        $restart_web = 'yes';
+        $restart_proxy = 'yes';
     }
 
     // Add SSL HSTS
@@ -581,22 +583,28 @@ if (!empty($_POST['save'])) {
         check_return_code($return_var,$output);
         unset($output);
         $v_ssl_hsts = 'yes';
+        $restart_web = 'yes';
+        $restart_proxy = 'yes';
     }
     
     // Delete Force SSL
     if (( $v_ssl_forcessl == 'yes' ) && (empty($_POST['v_ssl_forcessl'])) && (empty($_SESSION['error_msg']))) {
-        exec (HESTIA_CMD."v-delete-web-domain-ssl-force ".$user." ".escapeshellarg($v_domain)." yes", $output, $return_var);
+        exec (HESTIA_CMD."v-delete-web-domain-ssl-force ".$user." ".escapeshellarg($v_domain), $output, $return_var);
         check_return_code($return_var,$output);
         unset($output);
         $v_ssl_forcessl = 'no';
+        $restart_web = 'yes';
+        $restart_proxy = 'yes';
     }
 
     // Delete SSL HSTS
     if (( $v_ssl_hsts == 'yes' ) && (empty($_POST['v_ssl_hsts'])) && (empty($_SESSION['error_msg']))) {
-        exec (HESTIA_CMD."v-delete-web-domain-ssl-hsts ".$user." ".escapeshellarg($v_domain)." yes", $output, $return_var);
+        exec (HESTIA_CMD."v-delete-web-domain-ssl-hsts ".$user." ".escapeshellarg($v_domain), $output, $return_var);
         check_return_code($return_var,$output);
         unset($output);
         $v_ssl_hsts = 'no';
+        $restart_web = 'yes';
+        $restart_proxy = 'yes';
     }
 
     // Delete web stats
@@ -822,7 +830,9 @@ if (!empty($_POST['save'])) {
         exec(HESTIA_CMD."v-change-web-domain-docroot ".$v_username." ".escapeshellarg($v_domain)." default",  $output, $return_var);
         check_return_code($return_var,$output);
         unset($output);    
-        unset($_POST['v-custom-doc-domain'], $_POST['v-custom-doc-folder']);    
+        unset($_POST['v-custom-doc-domain'], $_POST['v-custom-doc-folder']);
+        $restart_web = 'yes';
+        $restart_proxy = 'yes';    
     }
 
     if ( !empty($_POST['v-custom-doc-domain']) && !empty($_POST['v_custom_doc_root_check']) && $v_custom_doc_root_prepath.$v_custom_doc_domain.'/public_html'.$v_custom_doc_folder != $v_custom_doc_root){
@@ -838,7 +848,10 @@ if (!empty($_POST['save'])) {
             check_return_code($return_var,$output);
             unset($output);  
             $v_custom_doc_root = 1; 
+            
         }
+        $restart_web = 'yes';
+        $restart_proxy = 'yes';
     }else{
         unset($v_custom_doc_root);
     }   
@@ -848,6 +861,8 @@ if (!empty($_POST['save'])) {
         check_return_code($return_var,$output);
         unset($output);    
         unset($_POST['v-redirect']);
+        $restart_web = 'yes';
+        $restart_proxy = 'yes';
     }
     
     if (!empty($_POST['v-redirect']) && !empty($_POST['v-redirect-checkbox']) ){
@@ -860,7 +875,8 @@ if (!empty($_POST['save'])) {
             exec(HESTIA_CMD."v-add-web-domain-redirect ".$v_username." ".escapeshellarg($v_domain)." ".escapeshellarg($_POST['v-redirect'])." ".escapeshellarg($_POST['v-redirect-code']),  $output, $return_var);
             check_return_code($return_var,$output);
             unset($output);  
-     
+            $restart_web = 'yes';
+            $restart_proxy = 'yes';
             }
 
         }else {
@@ -871,8 +887,11 @@ if (!empty($_POST['save'])) {
                  exec(HESTIA_CMD."v-add-web-domain-redirect ".$v_username." ".escapeshellarg($v_domain)." ".escapeshellarg($_POST['v-redirect'])." ".escapeshellarg($_POST['v-redirect-code']),  $output, $return_var);
                  check_return_code($return_var,$output);
                  unset($output);  
+                 $restart_web = 'yes';
+                 $restart_proxy = 'yes';
              }
         }
+        
     }
     // Restart web server
     if (!empty($restart_web) && (empty($_SESSION['error_msg']))) {