]> git.pld-linux.org Git - packages/tenshi.git/blame - tenshi.init
- drop obsolete and outdated manual inclusion of rpm macros
[packages/tenshi.git] / tenshi.init
CommitLineData
5896d7e4
ER
1#!/bin/sh
2#
3# chkconfig: 345 29 69
4# description: tenshi
bb38a2aa
ER
5#
6# $Id$
5896d7e4
ER
7
8# Source function library
9. /etc/rc.d/init.d/functions
10
bb38a2aa
ER
11# Get service config - may override defaults
12[ -f /etc/sysconfig/tenshi ] && . /etc/sysconfig/tenshi
13
5896d7e4
ER
14# do some sanity check
15if 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
18fi
19
bb38a2aa
ER
20# configtest itself
21# must return non-zero if check failed
22# output is discarded if checkconfig is ran without details
23configtest() {
bfec0900
ER
24 /usr/sbin/tenshi -C -c /etc/tenshi/tenshi.conf
25 return $?
26}
27
bb38a2aa
ER
28# wrapper for configtest
29checkconfig() {
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)
5896d7e4 37 RETVAL=$?
bb38a2aa
ER
38 if [ $RETVAL = 0 ]; then
39 ok
40 else
41 fail
42 fi
43 [ "$out" ] && echo >&2 "$out"
5896d7e4 44 else
bb38a2aa
ER
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
5896d7e4 54 fi
cb8e6241
ER
55}
56
bb38a2aa
ER
57start() {
58 # Check if the service is already running?
cb8e6241 59 if [ -f /var/lock/subsys/tenshi ]; then
bb38a2aa
ER
60 msg_already_running "tenshi"
61 return
5896d7e4 62 fi
bb38a2aa
ER
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
71stop() {
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
83reload() {
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
96flush() {
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
109condrestart() {
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
cb8e6241
ER
119}
120
121RETVAL=0
122# See how we were called.
123case "$1" in
124 start)
bb38a2aa 125 start
cb8e6241
ER
126 ;;
127 stop)
bb38a2aa 128 stop
5896d7e4
ER
129 ;;
130 restart)
bb38a2aa 131 checkconfig
cb8e6241
ER
132 stop
133 start
5896d7e4 134 ;;
bb38a2aa
ER
135 try-restart)
136 condrestart 0
5896d7e4
ER
137 ;;
138 reload|force-reload)
bb38a2aa 139 reload
5896d7e4
ER
140 ;;
141 flush)
bb38a2aa
ER
142 flush
143 ;;
144 checkconfig|configtest)
145 checkconfig 1
146 ;;
147 status)
148 status tenshi
149 RETVAL=$?
5896d7e4
ER
150 ;;
151 *)
bb38a2aa 152 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|checkconfig|status}"
5896d7e4
ER
153 exit 3
154esac
155
156exit $RETVAL
This page took 0.097094 seconds and 5 git commands to generate.