#!/bin/sh# *** Kills firewall states on failover Mobile Data when WAN is up ***WAN_IF="igc1"CURRENT_TIME="$(date +"%c")"WAN_STATUS=`route -n show default | grep interface | awk '{print $2}'`if [ "$WAN_STATUS" = "$WAN_IF" ]; then # See if there are any active states on the mobile data apart from the ping monitor and possibly web gui MOBILE_NSTATES=`pfctl -s state | grep "192\.168\.5" | grep -v "192\.168\.5\.1:80" | wc -l` if [ "$MOBILE_NSTATES" -gt 1 ]; then echo "$CURRENT_TIME: MAINWAN is online, but connections remain on Mobile Data. Killing states." pfctl -F state ifconfig igc2 down;sleep 180;ifconfig igc2 up else echo "$CURRENT_TIME: ALL GOOD." fifi