#!/bin/sh

DAEMON=/usr/sbin/lpd
DOC=/usr/doc/lpr

test -x $DAEMON -a -e $DOC || exit 0

case "$1" in
  start)
	echo -n "Starting printer spooler: lpd"
	start-stop-daemon --start --quiet --exec $DAEMON
	echo "."
	;;
  stop)
	echo -n "Stopping printer spooler: lpd"
	start-stop-daemon --stop --quiet --pidfile /var/run/lpd.pid --exec $DAEMON
	PID=$(pidof lpd)
	test -n "$PID" && kill $PID
	echo "."
	;;
  restart|force-reload)
	echo -n "Restarting printer spooler: lpd"
	start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/lpd.pid --exec $DAEMON
	PID=$(pidof lpd)
	test -n "$PID" && kill $PID
	sleep 2
	start-stop-daemon --start --quiet --exec $DAEMON
	echo "."
	;;
  *)
        echo "Usage: /etc/init.d/lpd {start|stop|restart}"
        exit 1
esac

exit 0
