#!/bin/sh
#
# Start/stop the bootpd deamon.

#
# Contrary to what you might have expected, this file comes
# with the debian nfsroot package, as it wasn't included in
# the netstd package. (Maybe that's a bug?).
#
#
set -e

test -f /usr/sbin/bootpd || exit 0
PID=/var/run/bootpd.pid

case "$1" in
  start)
	if test -f $PID; then
	  echo "bootpd already running (or else remove $PID)"
	else
          start-stop-daemon --start --verbose --exec /usr/sbin/bootpd
  	  #sorry for the next hack, but the --pidfile for start-stop-daemon
	  #simply didn't work for me.
	  ps -a|grep [/]usr/sbin/bootpd|sed -e 's/ *//'|cut -d" " -f1\
	            >$PID
	fi
        ;;
  stop)
        #echo "Stopping bootpd daemon" 
        start-stop-daemon --stop  --verbose --exec /usr/sbin/bootpd
	rm $PID
        ;;
  *)
        echo "Usage: /etc/init.d/lpd {start|stop}"
        exit 1
esac

exit 0
