Procházet zdrojové kódy

Ubuntu/Debian save iptables rules

Serghey Rodin před 11 roky
rodič
revize
e498d8786c
1 změnil soubory, kde provedl 12 přidání a 3 odebrání
  1. 12 3
      bin/v-update-firewall

+ 12 - 3
bin/v-update-firewall

@@ -126,8 +126,10 @@ if [ -x "$VESTA/data/firewall/custom.sh" ]; then
 fi
 
 # Checking fail2ban support
-chains=$VESTA/data/firewall/chains.conf
-for chain in $(cat $chains 2>/dev/null); do
+if [ ! -z "$FIREWALL_EXTENSION" ]; then
+    chains=$(cat $VESTA/data/firewall/chains.conf 2>/dev/null)
+fi
+for chain in $chains; do
     eval $chain
     if [[ "$PORT" =~ ,|-|: ]] ; then
         port="-m multiport --dports $PORT"
@@ -146,7 +148,14 @@ if [ -e "/etc/redhat-release" ]; then
         /sbin/chkconfig iptables on
     fi
 else
-    sbin/iptables-save > /etc/iptables.up.rules
+    /sbin/iptables-save > /etc/iptables.rules
+    preup="/etc/network/if-pre-up.d/iptables"
+    if [ ! -e "$preup" ]; then
+        echo '#!/bin/sh' > $preup
+        echo "/sbin/iptables-restore < /etc/iptables.rules" >> $preup
+        echo "exit 0" >> $preup
+        chmod +x $preup
+    fi
 fi