#!/bin/bash
THRESHOLD=4
num_of_rules=$(iptables -t nat -L PREROUTING --line-numbers | awk 'NR>2 {print $1}' | wc -l)

#Logging to syslog
/usr/bin/logger  -t $0 "NodeIptablesPreroutingRules auto-remediation initiated"

if [[ $num_of_rules -lt $THRESHOLD ]];then
    echo "stopping /etc/fw/fw"
    /etc/fw/fw stop
    echo "starting /etc/fw/fw"
    /etc/fw/fw start
fi

/usr/bin/logger  -t $0 "NodeIptablesPreroutingRules auto-remediation is done"
