summaryrefslogtreecommitdiff
path: root/office/dictd/config/rc.dictd
blob: 047c6c0cbd0ac47aaf10dc539372612d316bd7fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
# script courtesy of Sergio Vicari <sercari@esdebian.org>

DICTD=/usr/sbin/dictd

# DICTD_OPTIONS="-put -command_line -options -for -dictd -here"
DICTD_OPTIONS=""


PIDFILE=/var/run/dictd.pid

start() {

    if [ -x $DICTD ]; then
        echo "dictd starting."
        $DICTD $DICTD_OPTIONS
    else
        echo "rc.dictd: cannot find $DICTD or it's not executable"
    fi
}

stop() {
  if [ -e "$PIDFILE" ]; then
    echo "Stopping the dictd server."
    pid=$(cat $PIDFILE)
    kill $pid 1> /dev/null 2> /dev/null
    # Just in case:
    killall dictd 1> /dev/null 2> /dev/null
    rm -f $PIDFILE
  fi
}
reload() {
  echo "Reloading dictd."
  if [ -e "$PIDFILE" ]; then
    pid=$(cat $PIDFILE)
    kill -HUP $pid
  else
    killall -HUP dictd
  fi
}

status() {
  if [ -e /var/run/dictd.pid ]; then
    echo "the dictd server is running."
  else
    echo "dictd server is stopped."
  fi
}

# See how we were called.
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    stop
    start
    ;;
  reload)
    reload
    ;;
  status)
    status
    ;;
  *)
    echo $"Usage: $0 {start|stop|restart|reload|status}"
    ;;
esac