Version 2.0.58
[idzebra-moved-to-github.git] / rpm / zebrasrv.init
1 #!/bin/bash
2 #
3 # zebrasrv      Startup script for zebrasrv
4 #
5 # chkconfig: 2345 85 15
6 # description: Index Data Zebra server
7 # processname: zebrasrv-2.0
8 # config: /etc/idzebra/zebra.cfg
9 # config: /etc/sysconfig/zebrasrv
10 # pidfile: /var/run/zebrasrv.pid
11
12 . /etc/rc.d/init.d/functions
13
14 OPTIONS="-l /var/log/zebrasrv.log -u nobody tcp:@6:2100"
15
16 if [ -f /etc/sysconfig/zebrasrv ]; then
17         . /etc/sysconfig/zebrasrv
18 fi
19 CONFIG=${CONFIG-/etc/idzebra/zebra.cfg}
20 DAEMON=${DAEMON-/usr/bin/zebrasrv-2.0}
21 prog=zebrasrv
22 pidfile=${PIDFILE-/var/run/zebrasrv.pid}
23 lockfile=${LOCKFILE-/var/lock/subsys/zebrasrv}
24 RETVAL=0
25
26 if [ ! -f $CONFIG ]; then
27         echo "$prog: No $CONFIG"
28         exit 0
29 fi
30
31 start() {
32         echo -n $"Starting $prog: "
33         daemon --pidfile=${pidfile} $DAEMON $OPTIONS -D -c $CONFIG -p ${pidfile}
34         RETVAL=$?
35         echo
36         [ $RETVAL = 0 ] && touch ${lockfile}
37         return $RETVAL
38 }
39
40 stop() {
41         echo -n $"Stopping $prog: "
42         killproc -p ${pidfile} -d 10 $DAEMON
43         RETVAL=$?
44         echo
45         [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
46 }
47 reload() {
48     stop
49     start
50 }
51
52 # See how we were called.
53 case "$1" in
54   start)
55         start
56         ;;
57   stop)
58         stop
59         ;;
60   status)
61         status -p ${pidfile} $DAEMON
62         RETVAL=$?
63         ;;
64   restart)
65         stop
66         start
67         ;;
68   condrestart)
69         if [ -f ${pidfile} ] ; then
70                 stop
71                 start
72         fi
73         ;;
74   reload)
75         reload
76         ;;
77   *)
78         echo $"Usage: $prog {start|stop|restart|help}"
79         exit 1
80 esac
81
82 exit $RETVAL