#!/bin/sh
#
# snake-server:	Start/stop snake tree hosting service
#
# Copyright 2007 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# general public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# chkconfig:	- 97 01
# description:	Smart Network Automated Kickstart Environment Server
#

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

# Source daemon options
if [ -f /etc/sysconfig/snake-server ]; then
    . /etc/sysconfig/snake-server
fi

daemon=/usr/sbin/snake-server
lockfile=${LOCKFILE-/var/lock/subsys/snake-server}
RETVAL=0

start()
{
	echo -n $"Starting snake-server:"
    daemon $daemon $OPTIONS
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch ${lockfile}
}

stop()
{
	echo -n "Stopping snake-server:"
	killproc $daemon
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f ${lockfile}
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload)
    stop
    start
    ;;
  condrestart)
    [ -e ${lockfile} ] && (stop; start)
    ;;
  status)
    status snake-server
    RETVAL=$?
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
    exit 1
	;;
esac

exit $RETVAL
