]> git.pld-linux.org Git - packages/tenshi.git/blob - tenshi.init
- drop obsolete and outdated manual inclusion of rpm macros
[packages/tenshi.git] / tenshi.init
1 #!/bin/sh
2 #
3 # chkconfig:    345 29 69
4 # description:  tenshi
5 #
6 # $Id$
7
8 # Source function library
9 . /etc/rc.d/init.d/functions
10
11 # Get service config - may override defaults
12 [ -f /etc/sysconfig/tenshi ] && . /etc/sysconfig/tenshi
13
14 # do some sanity check
15 if grep -q sample /etc/tenshi/tenshi.conf; then
16         echo >&2 "Please configure /etc/tenshi/tenshi.conf before starting. Remove word 'sample' when done."
17         exit 1
18 fi
19
20 # configtest itself
21 # must return non-zero if check failed
22 # output is discarded if checkconfig is ran without details
23 configtest() {
24         /usr/sbin/tenshi -C -c /etc/tenshi/tenshi.conf
25         return $?
26 }
27
28 # wrapper for configtest
29 checkconfig() {
30         local details=${1:-0}
31
32         if [ $details = 1 ]; then
33                 # run config test and display report (status action)
34                 show "Checking %s configuration" "tenshi"; busy
35                 local out
36                 out=$(configtest 2>&1)
37                 RETVAL=$?
38                 if [ $RETVAL = 0 ]; then
39                         ok
40                 else
41                         fail
42                 fi
43                 [ "$out" ] && echo >&2 "$out"
44         else
45                 # run config test and abort with nice message if failed
46                 # (for actions checking status before action).
47                 configtest >/dev/null 2>&1
48                 RETVAL=$?
49                 if [ $RETVAL != 0 ]; then
50                         show "Checking %s configuration" "tenshi"; fail
51                         nls 'Configuration test failed. See details with %s "checkconfig"' $0
52                         exit $RETVAL
53                 fi
54         fi
55 }
56
57 start() {
58         # Check if the service is already running?
59         if [ -f /var/lock/subsys/tenshi ]; then
60                 msg_already_running "tenshi"
61                 return
62         fi
63
64         checkconfig
65         msg_starting "tenshi"
66         daemon /usr/sbin/tenshi -c /etc/tenshi/tenshi.conf -P /var/run/tenshi/tenshi.pid
67         RETVAL=$?
68         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/tenshi
69 }
70
71 stop() {
72         if [ ! -f /var/lock/subsys/tenshi ]; then
73                 msg_not_running "tenshi"
74                 return
75         fi
76
77         # Stop daemons.
78         msg_stopping "tenshi"
79         killproc tenshi
80         rm -f /var/lock/subsys/tenshi /var/run/tenshi/tenshi.pid
81 }
82
83 reload() {
84         if [ ! -f /var/lock/subsys/tenshi ]; then
85                 msg_not_running "tenshi"
86                 RETVAL=7
87                 return
88         fi
89
90         checkconfig
91         msg_reloading "tenshi"
92         killproc --pidfile /var/run/tenshi/tenshi.pid tenshi -HUP
93         RETVAL=$?
94 }
95
96 flush() {
97         if [ ! -f /var/lock/subsys/tenshi ]; then
98                 msg_not_running "tenshi"
99                 RETVAL=7
100                 return
101         fi
102
103         checkconfig
104         echo "Flushing all queues"
105         killproc --pidfile /var/run/tenshi/tenshi.pid tenshi -USR2
106         RETVAL=$?
107 }
108
109 condrestart() {
110         if [ ! -f /var/lock/subsys/tenshi ]; then
111                 msg_not_running "tenshi"
112                 RETVAL=$1
113                 return
114         fi
115
116         checkconfig
117         stop
118         start
119 }
120
121 RETVAL=0
122 # See how we were called.
123 case "$1" in
124   start)
125         start
126         ;;
127   stop)
128         stop
129         ;;
130   restart)
131         checkconfig
132         stop
133         start
134         ;;
135   try-restart)
136         condrestart 0
137         ;;
138   reload|force-reload)
139         reload
140         ;;
141   flush)
142         flush
143         ;;
144   checkconfig|configtest)
145         checkconfig 1
146         ;;
147   status)
148         status tenshi
149         RETVAL=$?
150         ;;
151   *)
152         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|checkconfig|status}"
153         exit 3
154 esac
155
156 exit $RETVAL
This page took 0.088575 seconds and 4 git commands to generate.