#!/bin/sh

# $Id: rc.omirrd,v 1.1 1996/08/14 22:53:54 luik Exp $
#
# rc.omirrd - omirrd startup script for System V based systems.
# Should be copied to /etc/init.d/omirrd, with links from /etc/rc?.d.
# Copyright (C) 1996, Andreas Luik <luik@pharao.s.bawue.de>.
#

# SBIN - where to find in.omirrd executable
SBIN=/usr/sbin
# VARRUN - where to find omirrd.pid file
VARRUN=/var/run
test -d /var/run && VARRUN=/var/run

case "$1" in
'start')
	if [ -f /etc/omirrd.conf -a -f $SBIN/in.omirrd ]; then
		$SBIN/in.omirrd
	fi
	;;
'stop')
	if [ -f $VARRUN/omirrd.pid ]; then
		pid=`head -1 $VARRUN/omirrd.pid`
		if [ "$pid" -gt 0 ]; then
			kill $pid 2>&1 | /usr/bin/grep -v "no such process"
		fi
	fi
	;;
'reload'|'force-reload')
	if [ -f $VARRUN/omirrd.pid ]; then
		pid=`head -1 $VARRUN/omirrd.pid`
		if [ "$pid" -gt 0 ]; then
			kill -HUP $pid
		fi
	else
		echo "omirrd not running" 1>&2
	fi
	;;
'restart')
	if [ -f $VARRUN/omirrd.pid ]; then
		pid=`head -1 $VARRUN/omirrd.pid`
		if [ "$pid" -gt 0 ]; then
			kill $pid 2>&1 | /usr/bin/grep -v "no such process"
			if [ -f /etc/omirrd.conf -a -f $SBIN/in.omirrd ]; then
				$SBIN/in.omirrd
			fi
		fi
	fi
	;;
*)
	echo "Usage: /etc/init.d/omirrd { start | stop | reload | force-reload | restart }"
	;;
esac
exit 0
