]> git.pld-linux.org Git - packages/tenshi.git/blob - tenshi.init
- update to 0.10
[packages/tenshi.git] / tenshi.init
1 #!/bin/sh
2 #
3 # chkconfig:    345 29 69
4 # description:  tenshi
5
6 # Source function library
7 . /etc/rc.d/init.d/functions
8
9 # do some sanity check
10 if grep -q sample /etc/tenshi/tenshi.conf; then
11         echo >&2 "Please configure /etc/tenshi/tenshi.conf before starting. Remove word 'sample' when done."
12         exit 1
13 fi
14
15 checkconfig() {
16         /usr/sbin/tenshi -C -c /etc/tenshi/tenshi.conf
17         return $?
18 }
19
20 start() {
21         # Check if the service is already running?
22         if [ ! -f /var/lock/subsys/tenshi ]; then
23                 msg_starting tenshi
24                 daemon /usr/sbin/tenshi -c /etc/tenshi/tenshi.conf -P /var/run/tenshi/tenshi.pid
25                 RETVAL=$?
26                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/tenshi
27         else
28                 msg_already_running tenshi
29         fi
30 }
31
32 stop() {
33         if [ -f /var/lock/subsys/tenshi ]; then
34                 msg_stopping tenshi
35                 killproc tenshi
36                 rm -f /var/run/tenshi/tenshi.pid /var/lock/subsys/tenshi >/dev/null 2>&1
37         else
38                 msg_not_running tenshi
39         fi
40 }
41
42 RETVAL=0
43 # See how we were called.
44 case "$1" in
45   start)
46         start
47         ;;
48   stop)
49         stop
50         ;;
51   restart)
52         stop
53         start
54         ;;
55   status)
56         status tenshi
57         exit $?
58         ;;
59   reload|force-reload)
60         if [ -f /var/lock/subsys/tenshi ]; then
61                 if checkconfig; then
62                         show "Reloading tenshi configuration and flushing all queues"
63                         kill -HUP `cat /var/run/tenshi/tenshi.pid`
64                         RETVAL=$?
65                         [ $RETVAL = 0 ] && ok || fail
66                 else
67                         show "The tenshi config file has syntax error, not restarting"; fail
68                         RETVAL=7
69                 fi
70         else
71                 msg_not_running tenshi
72                 RETVAL=7
73         fi
74         ;;
75   flush)
76         if [ -f /var/lock/subsys/tenshi ]; then
77                 echo "Flushing all queues"
78                 kill -USR2 `cat /var/run/tenshi/tenshi.pid`
79                 RETVAL=$?
80         else
81                 msg_not_running tenshi
82                 RETVAL=7
83         fi
84         ;;
85   *)
86         msg_usage "$0 {start|stop|restart|reload|force-reload|status|flush}"
87         exit 3
88 esac
89
90 exit $RETVAL
This page took 0.600599 seconds and 3 git commands to generate.