Skip to content

Commit e7c06f4

Browse files
authored
Fix save port changes in chains.conf (hestiacp#2813)
* Port not set correctly in chain.conf up on installing Hestia * Improve code * Change order loading hestia port detection
1 parent b178b97 commit e7c06f4

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

bin/v-add-firewall-chain

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ protocol=$(echo $protocol|tr '[:lower:]' '[:upper:]')
2020
# Defining absolute path to iptables
2121
iptables="/sbin/iptables"
2222

23-
# Get hestia port by reading nginx.conf
24-
hestiaport=$(grep 'listen' $HESTIA/nginx/conf/nginx.conf | awk '{print $2}' | sed "s|;||")
25-
if [ -z "$hestiaport" ]; then
26-
hestiaport=8083
27-
fi
28-
2923
# Includes
3024
# shellcheck source=/etc/hestiacp/hestia.conf
3125
source /etc/hestiacp/hestia.conf
@@ -36,6 +30,12 @@ source $HESTIA/func/firewall.sh
3630
# load config file
3731
source_conf "$HESTIA/conf/hestia.conf"
3832

33+
# Get hestia port by reading nginx.conf
34+
hestiaport=$(grep 'listen' $HESTIA/nginx/conf/nginx.conf | awk '{print $2}' | sed "s|;||")
35+
if [ -z "$hestiaport" ]; then
36+
hestiaport=8083
37+
fi
38+
3939
#----------------------------------------------------------#
4040
# Verifications #
4141
#----------------------------------------------------------#

bin/v-change-sys-port

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,8 @@ else
7272
sed -i "/hestia_port/c\hestia_port = $PORT" /etc/rainloop/data/_data_/_default_/configs/plugin-hestia-change-password.ini
7373
fi
7474
sed -i "/COMMENT='HESTIA'/c\RULE='2' ACTION='ACCEPT' PROTOCOL='TCP' PORT='$PORT' IP='0.0.0.0/0' COMMENT='HESTIA' SUSPENDED='no' TIME='07:40:16' DATE='2014-05-25'" $HESTIA/data/firewall/rules.conf
75-
76-
# Update F2B chains config
77-
if [ -f "$HESTIA/data/firewall/chains.conf" ]; then
78-
sed -i "s/PORT='$ORIGINAL_PORT'/PORT='$PORT'/g" $HESTIA/data/firewall/chains.conf
79-
fi
80-
75+
sed -i "/CHAIN='HESTIA'/c\CHAIN='HESTIA' PORT='$PORT' PROTOCOL='TCP'" $HESTIA/data/firewall/chains.conf
76+
8177
# Restart services
8278
if [ -n "$FIREWALL_SYSTEM" ] && [ "$FIREWALL_SYSTEM" != no ]; then
8379
$HESTIA/bin/v-restart-service iptables

0 commit comments

Comments
 (0)