RPM/Deb metaproxy.xml enables frontend_net logging
[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 ### BEGIN INIT INFO
13 # Provides:            metaproxy
14 # Required-Start:      $local_fs $remote_fs $network
15 # Required-Stop:       $local_fs $remote_fs
16 # Default-Start:       3 5
17 # Default-Stop:        0 1 2 6
18 # Short-Description:   Controls the metaproxy daemon
19 # Description:         Controls the Metaproxy Z39.50/SRU router.
20 ### END INIT INFO
21
22
23 # start of compatibility layer for RedHat/SuSE init.d
24 #
25 # rc_status exist on SuSE. Provide dummy if unavailable
26 if test -f /etc/rc.status; then
27         . /etc/rc.status
28 else
29         rc_status() {
30                 r=$?
31                 echo ""
32                 return $r
33         }
34 fi
35
36 # functions exist on RedHat. Provide tiny subset if unavailable
37 if test -f /etc/rc.d/init.d/functions; then
38         . /etc/rc.d/init.d/functions
39 else
40         daemon() {
41                 pid_file=""
42                 while test $# -gt 0; do
43                         case $1 in
44                                 --pidfile)
45                                         pid_file=$2
46                                         shift 2
47                                         ;;
48                                 *)
49                                         break;
50                                         ;;
51                         esac
52                 done
53                 startproc -p $pid_file $*
54         }
55
56         killproc() {
57                 pid_file=""
58                 delay=10
59                 while test $# -gt 0; do
60                         case $1 in
61                                 -p)
62                                         pid_file=$2
63                                         shift 2
64                                         ;;
65                                 -d)
66                                         delay=$2
67                                         shift 2
68                                         ;;
69                                 *)
70                                         break;
71                                         ;;
72                         esac
73                 done
74                 /sbin/killproc -p $pid_file $*
75         }
76         status() {
77                 pid_file=""
78                 while test $# -gt 0; do
79                         case $1 in
80                                 -p)
81                                         pid_file=$2
82                                         shift 2
83                                         ;;
84                                 *)
85                                         break;
86                                         ;;
87                         esac
88                 done
89                 if test -f $pid_file && kill -0 `cat $pid_file`; then
90                         echo "$DAEMON `cat $pid_file` is running"
91                         return 0
92                 fi
93                 echo "$DAEMON is not running"
94                 return 1
95         }
96 fi
97 # end of compatibility layer for RedHat/SuSE
98
99 . /etc/metaproxy/metaproxy.user
100
101 OPTIONS="-u $SERVER_USER -l /var/log/metaproxy.log -c /etc/metaproxy/metaproxy.xml"
102
103 if [ -f /etc/sysconfig/metaproxy ]; then
104         . /etc/sysconfig/metaproxy
105 fi
106
107 DAEMON=${DAEMON-/usr/bin/metaproxy}
108 prog=metaproxy
109 pidfile=${PIDFILE-/var/run/metaproxy.pid}
110 lockfile=${LOCKFILE-/var/lock/subsys/metaproxy}
111 RETVAL=0
112
113 start() {
114         echo -n $"Starting $prog: "
115         daemon --pidfile ${pidfile} $DAEMON $OPTIONS -D -p ${pidfile}
116         rc_status -v
117         RETVAL=$?
118         [ $RETVAL = 0 ] && touch ${lockfile}
119         return $RETVAL
120 }
121
122 stop() {
123         echo -n $"Stopping $prog: "
124         killproc -p ${pidfile} -d 10 $DAEMON
125         rc_status -v
126         RETVAL=$?
127         [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
128 }
129 reload() {
130         stop
131         start
132 }
133
134 # See how we were called.
135 case "$1" in
136         start)
137                 start
138                 ;;
139         stop)
140                 stop
141                 ;;
142         status)
143                 status -p ${pidfile} $DAEMON
144                 RETVAL=$?
145                 ;;
146         restart)
147                 stop
148                 start
149                 ;;
150         condrestart)
151                 if [ -f ${pidfile} ] ; then
152                         stop
153                         start
154                 fi
155                 ;;
156         reload)
157                 reload
158                 ;;
159         configtest)
160                 $DAEMON $OPTIONS -t
161                 RETVAL=$?
162                 ;;
163         *)
164                 echo $"Usage: $prog {start|stop|restart|help|configtest}"
165                 exit 1
166 esac
167
168 exit $RETVAL
169 # Local Variables:
170 # mode:shell-script
171 # sh-indentation: 8
172 # sh-basic-offset: 8
173 # End: