#!/bin/sh
check_current_states=$( pfctl -vvss | grep -e ', rule 97' -e '192.168.1.11' -e '192.168.1.15' )
res=1
resb=1
resc=1
case "$check_current_states" in 
  *", rule 97"* ) res=0 ;;
esac
case "$check_current_states" in
  *192.168.1.11* ) resb=0 ;;
esac
case "$check_current_states" in
  *192.168.1.15* ) resc=0 ;;
esac
if [ $res = 0 ] && [ $resb = 0 ]; 
then
  sysctl -q dev.gpio.2.led.1.pwm=1
  gpioctl -f /dev/gpioc2 3 duty 50 >/dev/null
  sysctl -q dev.gpio.2.led.2.pwm=1
  gpioctl -f /dev/gpioc2 7 duty 0 >/dev/null
  gpioctl -f /dev/gpioc2 6 duty 50 >/dev/null
elif [ $res = 0 ];
then
  sysctl -q dev.gpio.2.led.1.pwm=1
  gpioctl -f /dev/gpioc2 3 duty 0 >/dev/null
  sysctl -q dev.gpio.2.led.2.pwm=1
  gpioctl -f /dev/gpioc2 7 duty 0 >/dev/null
  gpioctl -f /dev/gpioc2 6 duty 50 >/dev/null
elif [ $resb = 0 ];
then
  sysctl -q dev.gpio.2.led.2.pwm=1
  gpioctl -f /dev/gpioc2 7 duty 0 >/dev/null
  gpioctl -f /dev/gpioc2 6 duty 0 >/dev/null
  sysctl -q dev.gpio.2.led.1.pwm=1
  gpioctl -f /dev/gpioc2 3 duty 50 >/dev/null
else
  sysctl -q dev.gpio.2.led.1.pwm=1
  gpioctl -f /dev/gpioc2 3 duty 0 >/dev/null
  sysctl -q dev.gpio.2.led.2.pwm=1
  gpioctl -f /dev/gpioc2 6 duty 0 >/dev/null
  gpioctl -f /dev/gpioc2 7 duty 50 >/dev/null
  
fi
if [ $resc = 0 ];
then
  sysctl -q dev.gpio.2.led.0.pwm=1
  gpioctl -f /dev/gpioc2 2 duty 50 >/dev/null
  gpioctl -f /dev/gpioc2 0 duty 50 >/dev/null
else
  sysctl -q dev.gpio.2.led.0.pwm=1
  gpioctl -f /dev/gpioc2 2 duty 0 >/dev/null
  gpioctl -f /dev/gpioc2 0 duty 0 >/dev/null

fi