]> git.pld-linux.org Git - packages/dictd.git/blob - dictd.init
- dictd.conf is autogenerated before start
[packages/dictd.git] / dictd.init
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), \
7 #               a TCP transaction based query/response protocol that allows \
8 #               a client to access dictionary definitions from a set of \
9 #               natural language dictionary databases.
10 # processname:  dictd
11 # config:       /etc/dictd.conf 
12 # config:       /etc/dictd/*
13
14 DAEMON_FILE=dictd
15 DAEMON_NAME="Dictionary Daemon"  
16 DAEMON_CONF=/etc/dictd.conf
17
18 generate_dictdconf() {
19     umask 022
20     if ls /etc/dictd/*.dictconf >/dev/null 2>&1; then 
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"\
23           >>$DAEMON_CONF
24         cat /etc/dictd/dictd-main.conf /etc/dictd/*.dictconf >>$DAEMON_CONF
25         return 0
26     fi 
27
28     echo "$0: no dictionaries found"
29     return 1    
30 }
31
32 # Source function library.
33 . /etc/rc.d/init.d/functions
34
35 # Get network config
36 . /etc/sysconfig/network
37
38 if is_no "${NETWORKING}"; then
39         msg_Network_Down ${DAEMON_FILE}
40         exit 1
41 fi
42
43 # Get sysconfig
44 [ -f /etc/sysconfig/${DAEMON_FILE} ] && . /etc/sysconfig/${DAEMON_FILE}
45
46 RETVAL=0
47 # See how we were called.
48 case "$1" in
49     start)
50         [ -x /usr/sbin/${DAEMON_FILE} ] || exit 0
51         if [ ! -f /var/lock/subsys/${DAEMON_FILE} ]; then
52                 if generate_dictdconf; then 
53                     msg_starting ${DAEMON_NAME}
54                     daemon ${DAEMON_FILE} ${DICTD_OPTS}
55                     pidofproc ${DAEMON_FILE} >/dev/null 2>&1
56                     RETVAL=$?
57                     [ $RETVAL -eq 0 ] && touch /var/lock/subsys/${DAEMON_FILE}
58                 else  
59                     exit 1
60                 fi    
61         else
62                 msg_Already_Running ${DAEMON_NAME}
63                 exit 1
64         fi
65         ;;
66     stop)
67         if [ -f /var/lock/subsys/${DAEMON_FILE} ]; then
68                 msg_stopping ${DAEMON_NAME}
69                 busy
70                 killproc /usr/sbin/${DAEMON_FILE} 
71                 rm -f /var/lock/subsys/${DAEMON_FILE} >/dev/null 2>&1
72         else
73                 msg_Not_Running ${DAEMON_NAME}
74                 exit 1
75         fi      
76         ;;
77   status)
78         status ${DAEMON_FILE}
79         ;;
80   restart|reload)
81         $0 stop
82         $0 start
83         ;;
84     *)
85         msg_Usage "$0 {start|stop|status|restart|reload}"
86         exit 1
87         ;;
88 esac
89
90 exit $RETVAL
This page took 0.058594 seconds and 4 git commands to generate.