#! /bin/sh

# /etc/init.d/atd: start and stop the at daemon

test -x /usr/sbin/atd || exit 0

# Configurable options:

case "$1" in
  start)
        echo -n "Starting at daemon: atd"
        mkdir -p /var/spool/at
	chmod a+w /var/spool/at
        start-stop-daemon --start --quiet -m --pidfile /var/run/atd.pid --exec /usr/sbin/atd /var/spool/at >/dev/null 2>&1 &
        echo "."
        ;;
  stop)
        echo -n "Stopping at daemon: atd"
        start-stop-daemon --stop --quiet --pidfile /var/run/atd.pid --exec /usr/sbin/atd
        rm -f /var/spool/at/trigger
        echo "."
        ;;

  *)
        echo "Usage: /etc/init.d/atd {start|stop}"
        exit 1
esac

exit 0


