#!/bin/sh

# Simple init script for starting
# the gateway service at boot time.
#
# Either add a call to it in /etc/rc.d/rc.local,
# or copy it to /etc/rc.d/init.d and symlink it
# to your runlevel.
#
# chkconfig: 2345 30 97
# description: nocathauth-gateway is the gateway portion of the \
#		nocatauth wireless network portal systtem
# processname: gateway
# config: /etc/nocat/gateway.conf
#
# Source function library.
. /etc/rc.d/init.d/functions

# Edit the following line if you installed the
# nocat software somewhere else.
#
NC=/usr/share/nocat/gw

export PERL5LIB=$NC/lib:$PERL5LIB
export NOCAT=/etc/nocat/gateway.conf

case "$1" in
  start)
        gprintf "Starting the NoCat gateway...\n"
	daemon $NC/bin/gateway
	RETVAL=$?
    	echo
    	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/gateway
    	;;
  stop)
	gprintf "Stopping the NoCat gateway...\n"
	daemon killall gateway
	RETVAL=$?
    	echo
    	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/gateway
        ;;
  restart|reload)
	$0 stop
	sleep 1
	$0 start
	;;
  status)
	status gateway
	RETVAL=$?
	;;
  *)
        gprintf "Usage: %s {start|stop|restart|reload|status}\n" "$0"
        exit 1
esac

#
# Ende
#
