#!/bin/bash
# IPitomy
# Auto-Provisioning Server
#
# chkconfig: - 85 15
# description: Auto-Provioning Server For IPitomy Phones, Ipitomy LLC init.d script


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

prog=prov
bin=/usr/local/sbin/$prog
#binD=/usr/sbin/${prog}d

pidfile=/var/run/${prog}.pid
lockfile=/var/lock/subsys/${prog}
RETVAL=0

start() {
        echo -n $"Starting $prog: "
		$bin &
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}
stop() {
	echo -n $"Stopping $prog: "
	killproc $bin
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
    echo -n $"Reloading $prog: "
    killproc $bin -HUP
    RETVAL=$?
    echo
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
        status $bin
	RETVAL=$?
	;;
  restart)
	stop
	start
	;;
  condrestart)
	if [ -f ${pidfile} ] ; then
		stop
		start
	fi
	;;
  reload)
        reload
	;;
  *)
	echo $"Usage: $prog {start|stop|restart|condrestart|help}"
	exit 1
esac

exit $RETVAL
