#!/bin/bash
#
#	/etc/rc.d/init.d/rarpd
#
# Starts the rarpd daemon
#
# chkconfig: - 82 16
# description: Server Reverse Address Resolution Protocol requests.
# processname: rarpd

### BEGIN INIT INFO
# Provides: rarpd
# Required-Start: $syslog $network
# Required-Stop:  $syslog $network
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: start and stop rarpd
# Description: RARP (Reverse Address Resolution Protocol) is a protocol \
#              which allows individual devices on an IP network to get \
#              their own IP addresses from the RARP server. \
### END INIT INFO

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

# Read the config file if exists
if [ -f /etc/sysconfig/rarpd ]; then
 . /etc/sysconfig/rarpd
fi

RETVAL=0
prog="rarpd"


start() {
    #if these files don't exist rarpd can't work
    test -x /usr/sbin/rarpd -a -f /etc/ethers || exit 6
	# Check if rarpd is already running
	#if [ ! -f /var/lock/subsys/rarpd ]; then
    status rarpd;
    if [ $? -ne 0 ]; then
	    echo -n $"Starting $prog: "
	    daemon /usr/sbin/rarpd $OPTIONS $INTERFACE
	    RETVAL=$?
	    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/rarpd
	    echo
	fi
	return $RETVAL
}

stop() {
	echo -n $"Stopping $prog: "
	killproc /usr/sbin/rarpd
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/rarpd
	echo
	return $RETVAL
}
reload() {
    RETVAL=3
}

#
#	See how we were called.
#
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  reload)
    reload
    ;;
  force-reload|restart)
    stop
	start
	;;
  condrestart)
	if [ -f /var/lock/subsys/rarpd ]; then
	    stop
	    start
	fi
	;;
  status)
	status rarpd
	RETVAL=$?
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|condrestart|reload|status|force-reload}"
	RETVAL=2
    
esac

exit $RETVAL
