Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > f30ad01d7e1b1ae697006e2bc413a42d > files > 3

pxe-1.2.0-8mdk.i586.rpm

#!/bin/bash
#
# Startup script handle the initialisation of PXE daemon
#
# chkconfig: 345 56 54
#
# description: A Preboot Execution Environment (PXE) Server.  This 
# server will allow you to network boot other PXE based machines.
#
# Script Authors: Erwan Velu <erwan@mandrakesoft.com>
#		  Antoine Ginies <aginies@mandrakesoft.com>
#
# Based on init script for pxe of Intel
#
#
# config: /etc/pxe.conf

# Source function library.
INTERFACE=eth0
. /etc/rc.d/init.d/functions

RETVAL=0
#
#	See how we were called.
#
case "$1" in
  start)
	if [ "$(pidof dhcpd)" = "" ]; then
                gprintf "Dhcp server is not running on this machine !\n"
		gprintf "Be sure that a valid PXE Dhcp server is running on your network\n"
        fi

  	if [ ! -f /etc/pxe.conf ]; then
	        gprintf "/etc/pxe.conf is not present !\n"
	        exit -1
	fi

	if [ ! -x /usr/sbin/pxe ]; then
	        gprintf "/usr/sbin/pxe is not executable !\n"
	        exit -1
	fi

	# Check if pxe is already running
	if [ ! -f /var/lock/subsys/pxe ]; then
	    route add -host 255.255.255.255 $INTERFACE 1> /dev/null 2> /dev/null
	    route add -net 224.0.0.0 netmask 224.0.0.0 $INTERFACE 1> /dev/null 2>/dev/null
	    echo -n 'Starting PXE server'
	    daemon /usr/sbin/pxe -c /etc/pxe.conf
	    RETVAL=$?
	    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pxe
	    echo
	else	   
	    echo -n 'PXE server already started !'
	    echo 
	fi
	;;
  stop)
	#action "Stopping pxe daemon: " 
	route del 255.255.255.255 2>/dev/null
	route del -net 224.0.0.0/3 2>/dev/null
	echo -n 'Stopping PXE server'
	killproc /usr/sbin/pxe
	rm -f /tmp/pxe.pid
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/pxe
	echo
	;;
  reload|restart)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  status)
	status /usr/sbin/pxe
	RETVAL=$?
	;;
  *)
	gprintf "Usage: /etc/rc.d/init.d/pxe {start|stop|restart|reload|status}\n"
	exit 1
esac

exit $RETVAL