Inserted the debug funcion.

This commit is contained in:
2022-02-07 13:55:31 +01:00
parent 2d55c50588
commit 20ffe596b6

View File

@@ -1,16 +1,32 @@
#!/bin/sh #!/bin/sh
# Debugging function
debug() {
if [ $DEBUG -eq 1 ]; then
echo "DEBUG: "$1 $2 $3
fi;
}
# Task type variables # Task type variables
NSENTER=$NSENTER NSENTER=$NSENTER
PREROUTING=$PREROUTING PREROUTING=$PREROUTING
POSTROUTING=$POSTROUTING POSTROUTING=$POSTROUTING
# Mandatory task variables # Mandatory task variables
NAME=$NAME-$COMMENT
CHAIN=$CHAIN CHAIN=$CHAIN
NAME=$NAME
COMMENT=$COMMENT COMMENT=$COMMENT
NAME=$NAME-$COMMENT
PROTOCOL=$TYPE PROTOCOL=$TYPE
EXTRA_OPTIONS="$2 $3 $4"
# turn on debug mode by extra option "debug"
if [[ "$(echo "$EXTRA_OPTIONS" | grep debug)" != "" ]] ; then
DEBUG=1
fi;
############################## ##############################
echo 1 > /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/ipv4/ip_forward
@@ -81,6 +97,8 @@ if [[ "$NSENTER" == "true" ]] ; then
if [[ "$PREROUTING" == "true" ]] || [[ "$POSTROUTING" == "true" ]] ; then if [[ "$PREROUTING" == "true" ]] || [[ "$POSTROUTING" == "true" ]] ; then
iptables="nsenter -t $(docker inspect --format {{.State.Pid}} $NAME) -n -- $IPTABLES -t nat"; iptables="nsenter -t $(docker inspect --format {{.State.Pid}} $NAME) -n -- $IPTABLES -t nat";
debug "iptables: "$IPTABLES;
if [[ "$PREROUTING" == "true" ]] ; then if [[ "$PREROUTING" == "true" ]] ; then
prerouting; prerouting;