# config: /etc/sysconfig/metaproxy
# pidfile: /var/run/metaproxy.pid
-# Source function library.
-. /etc/rc.d/init.d/functions
+### BEGIN INIT INFO
+# Provides: metaproxy
+# Required-Start: $local_fs $remote_fs $network
+# Required-Stop: $local_fs $remote_fs
+# Default-Start: 3 5
+# Default-Stop: 0 1 2 6
+# Short-Description: Controls the metaproxy daemon
+# Description: Controls the Metaproxy Z39.50/SRU router.
+### END INIT INFO
-OPTIONS="-u nobody -l /var/log/metaproxy.log -c /etc/metaproxy/metaproxy.xml"
+
+# start of compatibility layer for RedHat/SuSE init.d
+#
+# rc_status exist on SuSE. Provide dummy if unavailable
+if test -f /etc/rc.status; then
+ . /etc/rc.status
+else
+ rc_status() {
+ r=$?
+ echo ""
+ return $r
+ }
+fi
+
+# functions exist on RedHat. Provide tiny subset if unavailable
+if test -f /etc/rc.d/init.d/functions; then
+ . /etc/rc.d/init.d/functions
+else
+ daemon() {
+ pid_file=""
+ while test $# -gt 0; do
+ case $1 in
+ --pidfile)
+ pid_file=$2
+ shift 2
+ ;;
+ *)
+ break;
+ ;;
+ esac
+ done
+ startproc -p $pid_file $*
+ }
+
+ killproc() {
+ pid_file=""
+ delay=10
+ while test $# -gt 0; do
+ case $1 in
+ -p)
+ pid_file=$2
+ shift 2
+ ;;
+ -d)
+ delay=$2
+ shift 2
+ ;;
+ *)
+ break;
+ ;;
+ esac
+ done
+ /sbin/killproc -p $pid_file $*
+ }
+ status() {
+ pid_file=""
+ while test $# -gt 0; do
+ case $1 in
+ -p)
+ pid_file=$2
+ shift 2
+ ;;
+ *)
+ break;
+ ;;
+ esac
+ done
+ if test -f $pid_file && kill -0 `cat $pid_file`; then
+ echo "$DAEMON `cat $pid_file` is running"
+ return 0
+ fi
+ echo "$DAEMON is not running"
+ return 1
+ }
+fi
+# end of compatibility layer for RedHat/SuSE
+
+. /etc/metaproxy/metaproxy.user
+
+OPTIONS="-u $SERVER_USER -l /var/log/metaproxy.log -c /etc/metaproxy/metaproxy.xml"
if [ -f /etc/sysconfig/metaproxy ]; then
. /etc/sysconfig/metaproxy
start() {
echo -n $"Starting $prog: "
- daemon --pidfile=${pidfile} $DAEMON $OPTIONS -D -p ${pidfile}
+ daemon --pidfile ${pidfile} $DAEMON $OPTIONS -D -p ${pidfile}
+ rc_status -v
RETVAL=$?
- echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $DAEMON
+ rc_status -v
RETVAL=$?
- echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
+
reload() {
- stop
- start
+ echo -n $"Reloading $prog: "
+ $DAEMON $OPTIONS -t >/dev/null 2>&1
+ RETVAL=$?
+ if [ $RETVAL = 0 ]; then
+ killproc -p ${pidfile} $DAEMON -USR1 >/dev/null 2>&1
+ RETVAL=$?
+ if [ $RETVAL = 0 ]; then
+ i=0
+ p=`cat ${pidfile}`
+ while [ -d /proc/$p -a $i -lt 100 ]; do
+ i=`expr $i + 1`
+ usleep 50000
+ done
+ if [ -d /proc/$p ]; then
+ echo_failure
+ rc_status -v
+ RETVAL=1
+ else
+ rm -f ${pidfile}
+ fi
+ else
+ echo_failure
+ rc_status -v
+ fi
+ else
+ echo_failure
+ rc_status -v
+ echo $"not reloading due to configuration syntax error"
+ fi
+ if [ $RETVAL = 0 ]; then
+ daemon --pidfile ${pidfile} $DAEMON $OPTIONS -D -p ${pidfile}
+ rc_status -v
+ RETVAL=$?
+ [ $RETVAL = 0 ] && touch ${lockfile}
+ fi
+ return $RETVAL
}
# See how we were called.
case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- status -p ${pidfile} $DAEMON
- RETVAL=$?
- ;;
- restart)
- stop
- start
- ;;
- condrestart)
- if [ -f ${pidfile} ] ; then
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ status -p ${pidfile} $DAEMON
+ RETVAL=$?
+ ;;
+ restart)
stop
start
- fi
- ;;
- reload)
- reload
- ;;
- configtest)
- $DAEMON $OPTIONS -t
- RETVAL=$?
- ;;
- *)
- echo $"Usage: $prog {start|stop|restart|help|configtest}"
- exit 1
+ ;;
+ condrestart)
+ if [ -f ${pidfile} ] ; then
+ stop
+ start
+ fi
+ ;;
+ reload)
+ if [ -f ${pidfile} ] ; then
+ reload
+ fi
+ ;;
+ configtest)
+ $DAEMON $OPTIONS -t
+ RETVAL=$?
+ ;;
+ *)
+ echo $"Usage: $prog {start|stop|restart|help|configtest}"
+ exit 1
esac
exit $RETVAL
+# Local Variables:
+# mode:shell-script
+# sh-indentation: 8
+# sh-basic-offset: 8
+# End: