]>
Commit | Line | Data |
---|---|---|
06487908 | 1 | #!/bin/sh |
2 | # | |
3 | # dictd: Starts the Dictionary Daemon | |
4 | # | |
5 | # chkconfig: 345 90 10 | |
6 | # description: This is a daemon for the Dictionary Server Protocol (DICT), \ | |
cb7693d7 | 7 | # a TCP transaction based query/response protocol that allows \ |
8 | # a client to access dictionary definitions from a set of \ | |
06487908 | 9 | # natural language dictionary databases. |
10 | # processname: dictd | |
639b8279 | 11 | # config: /etc/dictd.conf |
cb7693d7 | 12 | # config: /etc/dictd/* |
06487908 | 13 | |
14 | DAEMON_FILE=dictd | |
639b8279 | 15 | DAEMON_NAME="Dictionary Daemon" |
ed9429da | 16 | DAEMON_CONF=/etc/dictd.conf |
06487908 | 17 | |
ed9429da | 18 | generate_dictdconf() { |
19 | umask 022 | |
639b8279 | 20 | if ls /etc/dictd/*.dictconf >/dev/null 2>&1; then |
ed9429da | 21 | echo "# DO NOT EDIT! This file is autogenerated by $0." >$DAEMON_CONF |
22 | echo "# To configure dictd edit /etc/dictd/* files and restart daemon"\ | |
cb7693d7 | 23 | >>$DAEMON_CONF |
ed9429da | 24 | cat /etc/dictd/dictd-main.conf /etc/dictd/*.dictconf >>$DAEMON_CONF |
25 | return 0 | |
639b8279 | 26 | fi |
ed9429da | 27 | |
cb7693d7 | 28 | echo "$0: $(nls 'no dictionaries found')" |
639b8279 | 29 | return 1 |
ed9429da | 30 | } |
06487908 | 31 | |
32 | # Source function library. | |
33 | . /etc/rc.d/init.d/functions | |
34 | ||
35 | # Get network config | |
36 | . /etc/sysconfig/network | |
37 | ||
52c7bcfd | 38 | if is_yes "${NETWORKING}"; then |
3861aa2d | 39 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then |
52c7bcfd | 40 | msg_network_down ${DAEMON_FILE} |
41 | exit 1 | |
42 | fi | |
43 | else | |
44 | exit 0 | |
06487908 | 45 | fi |
46 | ||
47 | # Get sysconfig | |
48 | [ -f /etc/sysconfig/${DAEMON_FILE} ] && . /etc/sysconfig/${DAEMON_FILE} | |
49 | ||
50 | RETVAL=0 | |
51 | # See how we were called. | |
52 | case "$1" in | |
cb7693d7 | 53 | start) |
ed9429da | 54 | [ -x /usr/sbin/${DAEMON_FILE} ] || exit 0 |
06487908 | 55 | if [ ! -f /var/lock/subsys/${DAEMON_FILE} ]; then |
639b8279 | 56 | if generate_dictdconf; then |
cb7693d7 | 57 | msg_starting ${DAEMON_NAME} |
58 | daemon ${DAEMON_FILE} ${DICTD_OPTS} | |
59 | pidofproc ${DAEMON_FILE} >/dev/null 2>&1 | |
60 | RETVAL=$? | |
61 | [ $RETVAL -eq 0 ] && \ | |
62 | touch /var/lock/subsys/${DAEMON_FILE} | |
639b8279 | 63 | else |
cb7693d7 | 64 | exit 1 |
639b8279 | 65 | fi |
06487908 | 66 | else |
f178605c | 67 | msg_already_running ${DAEMON_NAME} |
06487908 | 68 | fi |
52c7bcfd | 69 | ;; |
cb7693d7 | 70 | stop) |
06487908 | 71 | if [ -f /var/lock/subsys/${DAEMON_FILE} ]; then |
72 | msg_stopping ${DAEMON_NAME} | |
639b8279 | 73 | killproc /usr/sbin/${DAEMON_FILE} |
06487908 | 74 | rm -f /var/lock/subsys/${DAEMON_FILE} >/dev/null 2>&1 |
75 | else | |
f178605c | 76 | msg_not_running ${DAEMON_NAME} |
639b8279 | 77 | fi |
06487908 | 78 | ;; |
79 | status) | |
52c7bcfd | 80 | status ${DAEMON_FILE} |
6796c89f | 81 | exit $? |
52c7bcfd | 82 | ;; |
6796c89f | 83 | restart|force-reload) |
52c7bcfd | 84 | $0 stop |
85 | $0 start | |
6796c89f | 86 | exit $? |
52c7bcfd | 87 | ;; |
06487908 | 88 | *) |
6796c89f | 89 | msg_usage "$0 {start|stop|restart|force-reload|status}" |
90 | exit 3 | |
06487908 | 91 | esac |
92 | ||
93 | exit $RETVAL |