#!/bin/sh
#
# pxe		pxe (Preboot eXecution Environment)
#
# chkconfig:	345 55 45
#
# description:	PXE (Preboot eXecution Environment) Server

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

# Get network config
. /etc/sysconfig/network

# Get service config
[ -f /etc/sysconfig/pxe ] && . /etc/sysconfig/pxe

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		msg_network_down pxe
		exit 1
	fi
else
	exit 0
fi
			
RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/pxe ]; then
		msg_starting pxe
		daemon /usr/sbin/pxe 
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/pxe		
	else
		msg_already_running pxe
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/pxe ]; then
		msg_stopping pxe
		killproc pxe
		rm -f /var/lock/subsys/pxe >/dev/null 2>&1
	else
		msg_not_running pxe
	fi	
	rm -f /var/run/pxe.pid >/dev/null 2>&1
	;;
  restart|reload|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  status)
	status pxe
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|init|restart|reload|force-reload|status}"
	exit 3
esac

exit $RETVAL
