Pārlūkot izejas kodu

Not yet working: run execute_dir but functions not exported

Laurent HUBERT 9 mēneši atpakaļ
vecāks
revīzija
8a990e7a12

+ 11 - 0
etc/post-start-stop-routing.example

@@ -0,0 +1,11 @@
+# Creates a routing rule to external interface
+if [ -z ${1:-}]
+then
+    external_if=eth0
+else
+    external_if=$1
+fi
+$do_action -t nat $IPTABLES_ADD $IT_INPUT -A $IT_POSTROUTING -s '10.1.0.0/24' -o $external_if -j MASQUERADE
+$do_action -t raw $IPTABLES_INSERT $IT_INPUT -I $IT_PREROUTING -i fwbr+ -j CT --zone 1
+$do_action -t nat $IPTABLES_INSERT $IT_INPUT -D $IT_POSTROUTING -s '10.1.0.0/24' -o $external_if -j MASQUERADE
+$do_action -t raw $IPTABLES_INSERT $IT_INPUT -D $IT_PREROUTING -i fwbr+ -j CT --zone 1

+ 11 - 0
etc/post-up-down-routing.example

@@ -0,0 +1,11 @@
+# Creates a routing rule to external interface
+if [ -z ${1:-}]
+then
+    external_if=eth0
+else
+    external_if=$1
+fi
+$do_action -t nat $IPTABLES_ADD $IT_INPUT -A $IT_POSTROUTING -s '10.1.0.0/24' -o $external_if -j MASQUERADE
+$do_action -t raw $IPTABLES_INSERT $IT_INPUT -I $IT_PREROUTING -i fwbr+ -j CT --zone 1
+$do_action -t nat $IPTABLES_INSERT $IT_INPUT -D $IT_POSTROUTING -s '10.1.0.0/24' -o $external_if -j MASQUERADE
+$do_action -t raw $IPTABLES_INSERT $IT_INPUT -D $IT_PREROUTING -i fwbr+ -j CT --zone 1

+ 10 - 9
scripts/execute_dir

@@ -4,7 +4,6 @@ if [ -z "${CONFIGURATION_DIR:-}" ]
 then
     CONFIGURATION_DIR=/etc/lfirewall
     . ${CONFIGURATION_DIR}/setup
-
 fi
 
 options=$(getopt -l "firewall-action,verbose" -o "fv" -- "$@")
@@ -48,15 +47,15 @@ do_action=${1:-}
 script_dir=${2:-}
 
 if [ -z "${do_action}" ] ; then
-    echo "ERROR: missing action" > &2
+    echo "ERROR: missing action" >&2
     exit 2
 fi
 if [ -z "${script_dir}" ] ; then
-    echo "ERROR: missing script directory" > &2
+    echo "ERROR: missing script directory" >&2
     exit 2
 fi
 
-if [ ${do_action} = "do_delete" && ${firewall_action} = "yes" ]
+if [ ${do_action} = "do_delete" ] && [ ${firewall_action} = "yes" ]
 then
     # We do nothing in that specific case
     # (post-up-down)
@@ -67,14 +66,16 @@ then
     exit
 fi
 
+set -x
 cd ${script_dir}
-for script_file in $(ls)
+for script_file in `ls`
 do
-    if [ -x ${scritp_file} ]
+    if [ -x ${script_file} ]
     then
         # If file is executable
-        ./${scritp_file} ${do_action}
+        ./${script_file} ${do_action}
+        echo "${script_dir}/${script_file} ${do_action} done"
     fi
 done
-
-cd -
+set +x
+cd - > /dev/null

+ 1 - 1
scripts/lfirewall

@@ -367,7 +367,7 @@ fw_execute_post_start_stop(){
 	local do_action
 	do_action=$1
 	set +eu
-	${CONFIGURATION_DIR}/execute_dir ${do_action} ${POST_UP_DOWN_SCRIPTS_DIR}
+	${CONFIGURATION_DIR}/execute_dir ${do_action} ${POST_START_STOP_SCRIPTS_DIR}
 	set -eu
 }
 

+ 2 - 2
scripts/setup

@@ -58,8 +58,8 @@ CONFIGURATION_FILE=${CONFIGURATION_DIR}/lfirewall.conf
 CONFIGURATION_LOCAL_FILE=${CONFIGURATION_DIR}/lfirewall.conf.local
 USER_RULES_IPTABLES=${CONFIGURATION_DIR}/iptables-user.v4
 USER_RULES_IPTABLES_6=${CONFIGURATION_DIR}/iptables-user.v6
-POST_UP_DOWN_SCRIPTS_DIR==${CONFIGURATION_DIR}/post-up-down.d
-POST_START_STOP_SCRIPTS_DIR==${CONFIGURATION_DIR}/post-up-down.d
+POST_UP_DOWN_SCRIPTS_DIR=${CONFIGURATION_DIR}/post-up-down.d
+POST_START_STOP_SCRIPTS_DIR=${CONFIGURATION_DIR}/post-start-stop.d