diff options
Diffstat (limited to 'udp2raw_script.sh')
-rw-r--r-- | udp2raw_script.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/udp2raw_script.sh b/udp2raw_script.sh new file mode 100644 index 000000000000..d955f5ec40bb --- /dev/null +++ b/udp2raw_script.sh @@ -0,0 +1,17 @@ +#!/bin/bash +CONF_FILE="$1" +TARGET="$2" +RULE=`/sbin/su -s /bin/bash nobody -c "/usr/bin/udp2raw -g --conf-file $CONF_FILE"` + +if [[ "$RULE" =~ ^(.*?)iptables\ \-I\ (.*?)\ \-j\ DROP(.*?)$ ]]; then + RULE="${BASH_REMATCH[2]}" +else + echo "Malformed output" + exit 1 +fi + +if [[ "$TARGET" == 'insert' ]]; then + /usr/bin/iptables -I $RULE -j DROP || exit 1 +elif [[ "$TARGET" == 'delete' ]]; then + /usr/bin/iptables -D $RULE -j DROP || exit 1 +fi |