File tree Expand file tree Collapse file tree 10 files changed +37
-25
lines changed
Expand file tree Collapse file tree 10 files changed +37
-25
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
3838check_hestia_demo_mode
3939
4040# Define variables for ipset configuration
41- ipset_hstobject=' ../../data/firewall/ipset'
41+ ipset_hstobject=' ../../../ data/firewall/ipset'
4242IPSET_BIN=" $( command -v ipset) "
4343IPSET_PATH=" $HESTIA /data/firewall/ipset"
4444
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ is_format_valid 'action' 'protocol' 'port_ext'
5252is_system_enabled " $FIREWALL_SYSTEM " ' FIREWALL_SYSTEM'
5353get_next_fw_rule
5454is_format_valid ' rule'
55- is_object_new ' ../../data/firewall/rules' ' RULE' " $rule "
55+ is_object_new ' ../../../ data/firewall/rules' ' RULE' " $rule "
5656if [ -n " $comment " ]; then
5757 is_format_valid ' comment'
5858fi
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ if [ ! -z "$comment" ]; then
4646 is_format_valid ' comment'
4747fi
4848is_system_enabled " $FIREWALL_SYSTEM " ' FIREWALL_SYSTEM'
49- is_object_valid ' ../../data/firewall/rules' ' RULE' " $rule "
49+ is_object_valid ' ../../../ data/firewall/rules' ' RULE' " $rule "
5050
5151if [[ " $ip " =~ ^ipset: ]]; then
5252 ipset_name=" ${ip# ipset: } "
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ is_format_valid 'ip_name'
2929is_system_enabled " $FIREWALL_SYSTEM " ' FIREWALL_SYSTEM'
3030
3131# Define variables for ipset configuration
32- ipset_hstobject=' ../../data/firewall/ipset'
32+ ipset_hstobject=' ../../../ data/firewall/ipset'
3333is_object_valid " $ipset_hstobject " ' LISTNAME' " $ip_name "
3434ip_version=" $( get_object_value " $ipset_hstobject " ' LISTNAME' " $ip_name " ' $IP_VERSION' ) "
3535
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ source_conf "$HESTIA/conf/hestia.conf"
2828check_args ' 1' " $# " ' RULE'
2929is_format_valid ' rule'
3030is_system_enabled " $FIREWALL_SYSTEM " ' FIREWALL_SYSTEM'
31- is_object_valid ' ../../data/firewall/rules' ' RULE' " $rule "
31+ is_object_valid ' ../../../ data/firewall/rules' ' RULE' " $rule "
3232
3333# Perform verification if read-only mode is enabled
3434check_hestia_demo_mode
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ csv_list() {
6767
6868check_args ' 1' " $# " ' RULE [FORMAT]'
6969is_number_format_valid " $rule " " rule id"
70- is_object_valid ' ../../data/firewall/rules' ' RULE' " $rule "
70+ is_object_valid ' ../../../ data/firewall/rules' ' RULE' " $rule "
7171
7272# ----------------------------------------------------------#
7373# Action #
Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ source_conf "$HESTIA/conf/hestia.conf"
2828check_args ' 1' " $# " ' RULE'
2929is_format_valid ' rule'
3030is_system_enabled " $FIREWALL_SYSTEM " ' FIREWALL_SYSTEM'
31- is_object_valid ' ../../data/firewall/rules' ' RULE' " $rule "
32- is_object_unsuspended ' ../../data/firewall/rules' ' RULE' " $rule "
31+ is_object_valid ' ../../../ data/firewall/rules' ' RULE' " $rule "
32+ is_object_unsuspended ' ../../../ data/firewall/rules' ' RULE' " $rule "
3333
3434# Perform verification if read-only mode is enabled
3535check_hestia_demo_mode
@@ -39,7 +39,7 @@ check_hestia_demo_mode
3939# ----------------------------------------------------------#
4040
4141# Suspending rule
42- update_object_value ../../data/firewall/rules RULE " $rule " ' $SUSPENDED' yes
42+ update_object_value ' ../../../ data/firewall/rules' ' RULE' " $rule " ' $SUSPENDED' yes
4343
4444# Updating system firewall
4545$BIN /v-update-firewall
Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ source_conf "$HESTIA/conf/hestia.conf"
2828check_args ' 1' " $# " ' RULE'
2929is_format_valid ' rule'
3030is_system_enabled " $FIREWALL_SYSTEM " ' FIREWALL_SYSTEM'
31- is_object_valid ' ../../data/firewall/rules' ' RULE' " $rule "
32- is_object_suspended ' ../../data/firewall/rules' ' RULE' " $rule "
31+ is_object_valid ' ../../../ data/firewall/rules' ' RULE' " $rule "
32+ is_object_suspended ' ../../../ data/firewall/rules' ' RULE' " $rule "
3333
3434# Perform verification if read-only mode is enabled
3535check_hestia_demo_mode
@@ -39,7 +39,7 @@ check_hestia_demo_mode
3939# ----------------------------------------------------------#
4040
4141# Suspending rule
42- update_object_value ../../data/firewall/rules RULE " $rule " ' $SUSPENDED' " no"
42+ update_object_value ' ../../../ data/firewall/rules' ' RULE' " $rule " ' $SUSPENDED' " no"
4343
4444# Updating system firewall
4545$BIN /v-update-firewall
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
3131# Perform verification if read-only mode is enabled
3232check_hestia_demo_mode
3333
34- ipset_hstobject=' ../../data/firewall/ipset'
34+ ipset_hstobject=' ../../../ data/firewall/ipset'
3535
3636for ipset_name in $( search_objects " $ipset_hstobject " ' SUSPENDED' ' no' ' LISTNAME' 2> /dev/null) ; do
3737
Original file line number Diff line number Diff line change 66# #
77# ===========================================================================#
88
9+ # Source conf function for correct variable initialisation
10+ source_conf () {
11+ while IFS=' = ' read -r lhs rhs; do
12+ if [[ ! $lhs =~ ^\ * # && -n $lhs ]]; then
13+ rhs= " ${rhs%% ^\# * } " # Del in line right comments
14+ rhs= " ${rhs%%* ( )} " # Del trailing spaces
15+ rhs= " ${rhs% \' * } " # Del opening string quotes
16+ rhs= " ${rhs# \' * } " # Del closing string quotes
17+ declare -g $lhs = " $rhs "
18+ fi
19+ done < $1
20+ }
21+
22+ if [ -z " $user " ]; then
23+ if [ -z " $ROOT_USER " ]; then
24+ if [ -z " $HESTIA " ]; then
25+ # shellcheck source=/etc/hestiacp/hestia.conf
26+ source /etc/hestiacp/hestia.conf
27+ fi
28+ source_conf " $HESTIA /conf/hestia.conf" # load config file
29+ fi
30+ user=" $ROOT_USER "
31+ fi
32+
933# Internal variables
1034HOMEDIR= ' /home'
1135BACKUP= ' /backup'
@@ -1570,18 +1594,6 @@ no_symlink_chmod() {
15701594 done
15711595}
15721596
1573- source_conf () {
1574- while IFS=' = ' read -r lhs rhs; do
1575- if [[ ! $lhs =~ ^\ * # && -n $lhs ]]; then
1576- rhs= " ${rhs%% ^\# * } " # Del in line right comments
1577- rhs= " ${rhs%%* ( )} " # Del trailing spaces
1578- rhs= " ${rhs% \' * } " # Del opening string quotes
1579- rhs= " ${rhs# \' * } " # Del closing string quotes
1580- declare -g $lhs = " $rhs "
1581- fi
1582- done < $1
1583- }
1584-
15851597format_no_quotes () {
15861598 exclude=" ['|\" ]"
15871599 if [[ " $1 " =~ $exclude ]]; then
You can’t perform that action at this time.
0 commit comments