#!/bin/bash
#
# p3scan startup script
#
# usage: p3scan { start | stop | restart | status }
#
# Jack S. Lai - laitcg@cox.net
### BEGIN INIT INFO
# Provides: p3scan
# Required-Start: shorewall
# Required-Stop: shorewall
# Default-Start: 2 3 5
# Default-Stop: 0 1 4 6
# Short-Description: P3Scan
# Description: P3scan

### END INIT INFO
. /etc/rc.d/init.d/functions


DAEMON_NAME=p3scan


case "$1" in
  start)
        gprintf "Starting %s: " $DAEMON_NAME
        # use --user to run the daemon under the specified uid
        daemon p3scan
        echo
        touch /var/lock/subsys/$DAEMON_NAME
        . /etc/p3scan/firewall.sh
        ;;
  stop)
        gprintf "Shutting down %s: " $DAEMON_NAME
        killproc $DAEMON_NAME
        echo
        rm -f /var/lock/subsys/$DAEMON_NAME
	/sbin/iptables --flush
	/etc/init.d/shorewall restart
        ;;
  status)
        status $DAEMON_NAME
        ;;
  reload|restart)
        $0 stop
        $0 start
        ;;
  *)
        gprintf "Usage: %s\n" "$0 {start|stop|restart|reload|status}"
        exit 1
esac

exit 0


