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

Fix save port changes in chains.conf (#2813)

* Port not set correctly in chain.conf up on installing Hestia

* Improve code

* Change order loading hestia port detection
Jaap Marcus 3 лет назад
Родитель
Сommit
e7c06f41b7
2 измененных файлов с 8 добавлено и 12 удалено
  1. 6 6
      bin/v-add-firewall-chain
  2. 2 6
      bin/v-change-sys-port

+ 6 - 6
bin/v-add-firewall-chain

@@ -20,12 +20,6 @@ protocol=$(echo $protocol|tr '[:lower:]' '[:upper:]')
 # Defining absolute path to iptables
 iptables="/sbin/iptables"
 
-# Get hestia port by reading nginx.conf
-hestiaport=$(grep 'listen' $HESTIA/nginx/conf/nginx.conf | awk '{print $2}' | sed "s|;||")
-if [ -z "$hestiaport" ]; then
-    hestiaport=8083
-fi
-
 # Includes
 # shellcheck source=/etc/hestiacp/hestia.conf
 source /etc/hestiacp/hestia.conf
@@ -36,6 +30,12 @@ source $HESTIA/func/firewall.sh
 # load config file
 source_conf "$HESTIA/conf/hestia.conf"
 
+# Get hestia port by reading nginx.conf
+hestiaport=$(grep 'listen' $HESTIA/nginx/conf/nginx.conf | awk '{print $2}' | sed "s|;||")
+if [ -z "$hestiaport" ]; then
+    hestiaport=8083
+fi
+
 #----------------------------------------------------------#
 #                    Verifications                         #
 #----------------------------------------------------------#

+ 2 - 6
bin/v-change-sys-port

@@ -72,12 +72,8 @@ else
         sed -i "/hestia_port/c\hestia_port = $PORT" /etc/rainloop/data/_data_/_default_/configs/plugin-hestia-change-password.ini
     fi
     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
-    
-    # Update F2B chains config
-    if [ -f "$HESTIA/data/firewall/chains.conf" ]; then
-        sed -i "s/PORT='$ORIGINAL_PORT'/PORT='$PORT'/g" $HESTIA/data/firewall/chains.conf
-    fi
-    
+    sed -i "/CHAIN='HESTIA'/c\CHAIN='HESTIA' PORT='$PORT' PROTOCOL='TCP'" $HESTIA/data/firewall/chains.conf
+     
     # Restart services
     if [ -n "$FIREWALL_SYSTEM" ] && [ "$FIREWALL_SYSTEM" != no ]; then
         $HESTIA/bin/v-restart-service iptables