#!/bin/sh
#
# portreserve  This script starts and stops the TCP port reserver
#
# chkconfig: 2345 10 89
#
# description: portreserve is a TCP port reservation utility.

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

prog=portreserve

# See how we were called.
case "$1" in
  start)
	# Start daemon.
	gprintf "Starting %s: " "$prog"
	daemon portreserve
	RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/portreserve
        ;;
  stop)
        # Stop daemon.
        action "Stopping %s: " "$prog" portrelease '*'
        RETVAL=$?
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/portreserve /var/lib/portreserve/portreserve.sock
        ;;
  restart|reload)
        $0 stop
        $0 start
        ;;
  condrestart)
       [ -e /var/lock/subsys/portreserve ] && $0 restart
       ;;
  status)
	status portreserve
	;;
  *)
	gprintf "Usage: %s {start|stop|restart|reload|status|condrestart}\n" "$0"
	exit 1
esac

exit 0
