]> git.pld-linux.org Git - packages/c-icap.git/blob - c-icap.init
- use pidfile for killproc and status
[packages/c-icap.git] / c-icap.init
1 #!/bin/sh
2 #
3 # c-icap        This shell script takes care of starting and stopping
4 #               c-icap ICAP server
5 #
6 # chkconfig:    345 90 10
7 #
8 # description:  c-icap ICAP server
9 #
10 # processname:  c-icap
11 # pidfile:      /var/run/c-icap/c-icap.pid
12 # config:       /etc/c-icap/c-icap.conf
13
14 # Source function library
15 . /etc/rc.d/init.d/functions
16
17 # Get network config
18 . /etc/sysconfig/network
19
20 # Get service config
21 [ -f /etc/sysconfig/c-icap ] && . /etc/sysconfig/c-icap
22
23 # Default pidfile location
24 c_icap_pidfile="/var/run/c-icap/c-icap.pid"
25
26 # Check that networking is up.
27 if is_yes "${NETWORKING}"; then
28         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status -a "$1" != init ]; then
29                 msg_network_down c-icap
30                 exit 1
31         fi
32 else
33         exit 0
34 fi
35
36 start() {
37         # Check if the service is already running?
38         if [ ! -f /var/lock/subsys/c-icap ]; then
39                 msg_starting c-icap
40                 daemon /usr/bin/c-icap
41                 RETVAL=$?
42                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/c-icap
43         else
44                 msg_already_running c-icap
45         fi
46 }
47
48 stop() {
49         if [ -f /var/lock/subsys/c-icap ]; then
50                 # Stop daemons.
51                 msg_stopping c-icap
52                 killproc --pidfile $c_icap_pidfile c-icap
53                 rm -f /var/lock/subsys/c-icap >/dev/null 2>&1
54         else
55                 msg_not_running c-icap
56         fi
57 }
58
59 restart() {
60         # if service is up, do configtest
61         if [ -f /var/lock/subsys/c-icap ]; then
62                 if [ $RETVAL != 0 ]; then
63                         exit 1
64                 fi
65         fi
66         stop
67         start
68 }
69
70 condrestart() {
71         # if service is up, do configtest
72         if [ -f /var/lock/subsys/c-icap ]; then
73                 if [ $RETVAL != 0 ]; then
74                         exit 1
75                 fi
76                 stop
77                 start
78         else
79                 msg_not_running c-icap
80                 RETVAL=0
81         fi
82 }
83
84 RETVAL=0
85 # See how we were called.
86 case "$1" in
87   start)
88         start
89         ;;
90   stop)
91         stop
92         ;;
93   restart)
94         restart
95         ;;
96   try-restart)
97         condrestart
98         ;;
99   reload|force-reload)
100         reload
101         ;;
102   status)
103         status --pidfile $c_icap_pidfile c-icap
104         exit $?
105         ;;
106   *)
107         msg_usage "$0 {start|stop|init|restart|try-restart|reload|force-reload|status}"
108         exit 3
109 esac
110
111 exit $RETVAL
This page took 0.155156 seconds and 3 git commands to generate.