#!/bin/sh

iptables=/sbin/iptables

case "$1" in
  start)
    if $0 status > /dev/null; then
      echo "ist schon aktiviert"
      exit 2
    fi
    
    echo "Enabling http access..."
    $iptables -A internet -p tcp --dport 80 -j ACCEPT
    ;;
  stop)
    echo "Disabling http access..."
    $iptables -D internet -p tcp --dport 80 -j ACCEPT
    ;;
  status)
    $iptables -L internet | grep "dpt:www" > /dev/null
    if test $? -eq 0; then
      echo "http access is ENABLED!"
      exit 0
    else
      echo "http access is disabled"
      exit 1
    fi
    ;;
  *)
    echo "Usage: $0 {start|stop|status}"
    exit 1;
    ;;
esac

exit 0

