Skip to content

Commit a27a9cb

Browse files
committed
Fix issues with config not loading correctly
1 parent b8ebc19 commit a27a9cb

File tree

3 files changed

+47
-15
lines changed

3 files changed

+47
-15
lines changed

bin/v-add-web-domain-redirect

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: Adding force redirect to domain
3-
# options: USER DOMAIN REDIRECT HTTPCODE
3+
# options: USER DOMAIN REDIRECT HTTPCODE [RESTART]
44
# labels: hestia web
55
#
66
# example: v-add-web-domain-redirect user domain.tld domain.tld
@@ -22,6 +22,7 @@ user=$1
2222
domain=$2
2323
redirect=$(echo $3 | idn);
2424
code=${4-301}
25+
restart=${5-no}
2526

2627
# Includes
2728
source $HESTIA/func/main.sh
@@ -31,7 +32,7 @@ source $HESTIA/conf/hestia.conf
3132
# Verifications #
3233
#----------------------------------------------------------#
3334

34-
check_args '3' "$#" 'USER DOMAIN REDIRECT [HTTP-CODE]'
35+
check_args '3' "$#" 'USER DOMAIN REDIRECT [HTTP-CODE] [RESTART]'
3536
is_format_valid 'user' 'domain'
3637
is_number_format_valid "$code" "code"
3738
is_object_valid 'user' 'USER' "$user"
@@ -101,9 +102,15 @@ fi
101102

102103
update_object_value 'web' 'DOMAIN' "$domain" '$REDIRECT' "$redirect"
103104
update_object_value 'web' 'DOMAIN' "$domain" '$REDIRECT_CODE' "$code"
104-
# Restart web server
105-
$BIN/v-restart-web
106-
check_result $? "Web restart failed" > /dev/null
105+
106+
if [ "$restart" = "yes" ]; then
107+
# Restarting web server
108+
$BIN/v-restart-web $restart
109+
check_result $? "Web restart failed" >/dev/null
110+
111+
$BIN/v-restart-proxy $restart
112+
check_result $? "Proxy restart failed" >/dev/null
113+
fi
107114

108115
# Logging
109116
log_history "Enable forced redirect $domain"

bin/v-delete-web-domain-redirect

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: Delete force redirect to domain
3-
# options: USER DOMAIN
3+
# options: USER DOMAIN [RESTART]
44
# labels: hestia web
55
#
66
# example: v-add-web-domain-redirect user domain.tld
@@ -15,7 +15,7 @@
1515
# Argument definition
1616
user=$1
1717
domain=$2
18-
redirect=$3
18+
restart=${3-no}
1919

2020

2121
# Includes
@@ -27,7 +27,7 @@ source $HESTIA/conf/hestia.conf
2727
# Verifications #
2828
#----------------------------------------------------------#
2929

30-
check_args '2' "$#" 'USER DOMAIN'
30+
check_args '2' "$#" 'USER DOMAIN [RESTART]'
3131
is_format_valid 'user' 'domain'
3232
is_object_valid 'user' 'USER' "$user"
3333
is_object_unsuspended 'user' 'USER' "$user"
@@ -59,9 +59,15 @@ fi
5959

6060
update_object_value 'web' 'DOMAIN' "$domain" '$REDIRECT' ""
6161
update_object_value 'web' 'DOMAIN' "$domain" '$REDIRECT_CODE' ""
62-
# Restart web server
63-
$BIN/v-restart-web
64-
check_result $? "Web restart failed" > /dev/null
62+
63+
if [ "$restart" = "yes" ]; then
64+
# Restarting web server
65+
$BIN/v-restart-web $restart
66+
check_result $? "Web restart failed" >/dev/null
67+
68+
$BIN/v-restart-proxy $restart
69+
check_result $? "Proxy restart failed" >/dev/null
70+
fi
6571

6672
# Logging
6773
log_history "Enable forced redirect $domain"

web/edit/web/index.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@
573573
check_return_code($return_var,$output);
574574
unset($output);
575575
$v_ssl_forcessl = 'yes';
576+
$restart_web = 'yes';
577+
$restart_proxy = 'yes';
576578
}
577579

578580
// Add SSL HSTS
@@ -581,22 +583,28 @@
581583
check_return_code($return_var,$output);
582584
unset($output);
583585
$v_ssl_hsts = 'yes';
586+
$restart_web = 'yes';
587+
$restart_proxy = 'yes';
584588
}
585589

586590
// Delete Force SSL
587591
if (( $v_ssl_forcessl == 'yes' ) && (empty($_POST['v_ssl_forcessl'])) && (empty($_SESSION['error_msg']))) {
588-
exec (HESTIA_CMD."v-delete-web-domain-ssl-force ".$user." ".escapeshellarg($v_domain)." yes", $output, $return_var);
592+
exec (HESTIA_CMD."v-delete-web-domain-ssl-force ".$user." ".escapeshellarg($v_domain), $output, $return_var);
589593
check_return_code($return_var,$output);
590594
unset($output);
591595
$v_ssl_forcessl = 'no';
596+
$restart_web = 'yes';
597+
$restart_proxy = 'yes';
592598
}
593599

594600
// Delete SSL HSTS
595601
if (( $v_ssl_hsts == 'yes' ) && (empty($_POST['v_ssl_hsts'])) && (empty($_SESSION['error_msg']))) {
596-
exec (HESTIA_CMD."v-delete-web-domain-ssl-hsts ".$user." ".escapeshellarg($v_domain)." yes", $output, $return_var);
602+
exec (HESTIA_CMD."v-delete-web-domain-ssl-hsts ".$user." ".escapeshellarg($v_domain), $output, $return_var);
597603
check_return_code($return_var,$output);
598604
unset($output);
599605
$v_ssl_hsts = 'no';
606+
$restart_web = 'yes';
607+
$restart_proxy = 'yes';
600608
}
601609

602610
// Delete web stats
@@ -822,7 +830,9 @@
822830
exec(HESTIA_CMD."v-change-web-domain-docroot ".$v_username." ".escapeshellarg($v_domain)." default", $output, $return_var);
823831
check_return_code($return_var,$output);
824832
unset($output);
825-
unset($_POST['v-custom-doc-domain'], $_POST['v-custom-doc-folder']);
833+
unset($_POST['v-custom-doc-domain'], $_POST['v-custom-doc-folder']);
834+
$restart_web = 'yes';
835+
$restart_proxy = 'yes';
826836
}
827837

828838
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 @@
838848
check_return_code($return_var,$output);
839849
unset($output);
840850
$v_custom_doc_root = 1;
851+
841852
}
853+
$restart_web = 'yes';
854+
$restart_proxy = 'yes';
842855
}else{
843856
unset($v_custom_doc_root);
844857
}
@@ -848,6 +861,8 @@
848861
check_return_code($return_var,$output);
849862
unset($output);
850863
unset($_POST['v-redirect']);
864+
$restart_web = 'yes';
865+
$restart_proxy = 'yes';
851866
}
852867

853868
if (!empty($_POST['v-redirect']) && !empty($_POST['v-redirect-checkbox']) ){
@@ -860,7 +875,8 @@
860875
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);
861876
check_return_code($return_var,$output);
862877
unset($output);
863-
878+
$restart_web = 'yes';
879+
$restart_proxy = 'yes';
864880
}
865881

866882
}else {
@@ -871,8 +887,11 @@
871887
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);
872888
check_return_code($return_var,$output);
873889
unset($output);
890+
$restart_web = 'yes';
891+
$restart_proxy = 'yes';
874892
}
875893
}
894+
876895
}
877896
// Restart web server
878897
if (!empty($restart_web) && (empty($_SESSION['error_msg']))) {

0 commit comments

Comments
 (0)