#! /bin/sh
# 
# Script to start and stop dictionary server daemon (/usr/sbin/dictd)
# written by Bob Hilliard <hilliard@debian.org> 15 April 1988, last
# modified on 04 Decmeber 2005.
# based on /etc/init.d/skeleton v1.7  05-May-1997  by miquels@cistron.nl

# dictd now writes a pid file before it drops root permissions (in favor of
# dictd.dictd), so we no longer start it with -c dictd.

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:$PATH
DAEMON=/usr/sbin/dictd
NAME=dictd
DESC="dictionary server"
PIDFILE=/var/run/dictd.pid

test -f $DAEMON || exit 0

. /etc/default/dictd

set -e

case "$1" in
  start)
    echo -n "Starting $DESC: $NAME"
    start-stop-daemon --start -o --exec $DAEMON -- ${DICTD_ARGS}
    echo "."
    ;;
  stop)
    echo -n "Stopping $DESC: $NAME"
    start-stop-daemon --stop -o --pidfile $PIDFILE --exec $DAEMON
    rm -f $PIDFILE
    echo "."
    ;;
  restart|force-reload)
    echo -n "Restarting $DESC: $NAME"
    start-stop-daemon --stop -o --pidfile $PIDFILE --exec $DAEMON
    rm -f $PIDFILE
    sleep 1
    start-stop-daemon --start -o --exec $DAEMON -- ${DICTD_ARGS}
    echo "."
    ;;
  reload)
   echo -n "Reloading configuration files for $DESC: $NAME"
    start-stop-daemon --stop --signal 1 -o --quiet --pidfile $PIDFILE --exec $DAEMON
    echo "."
    ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload}"
    exit 1
    ;;
esac

exit 0
