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