#! /bin/sh
# Copyright (c) 2001-2002 SuSE GmbH Nuernberg, Germany.
#
# Author: Bjrn Jacke <feedback@suse.de>, 2001
#         Thorsten Kukuk <feedback@suse.de>, 2001
#
# /etc/init.d/radvd
#   and its symbolic link
# /usr/sbin/rcradvd
#
# System startup script for the router advertisement daemon
#
### BEGIN INIT INFO
# Provides:       radvd
# Required-Start: $remote_fs $named $syslog
# Required-Stop:  $remote_fs $named $syslog
# Default-Start:  3 5
# Default-Stop:   0 1 2 6
# Short-Description: router advertisement daemon
# Description:    router advertisement daemon
### END INIT INFO

DAEMON="router advertisement daemon"
DAEMON_BIN=/usr/sbin/radvd
DAEMON_CONF=/etc/radvd.conf
DAEMON_PIDDIR=/var/run/radvd
DAEMON_PIDFILE=$DAEMON_PIDDIR/radvd.pid

test -f /etc/sysconfig/radvd && . /etc/sysconfig/radvd

. /etc/rc.status

rc_reset

case "$1" in
    start)
	echo -n "Starting $DAEMON"
	if ! [ -f $DAEMON_CONF ]; then
		echo -e -n "... no configuration file found"
		rc_status -u
		rc_exit
	fi
	test -d $DAEMON_PIDDIR || install -d -m 755 -o radvd $DAEMON_PIDDIR
	start_daemon $DAEMON_BIN $RADVD_OPTIONS
	rc_status -v
	;;
    stop)
	echo -n "Shutting down $DAEMON"
	killproc -p $DAEMON_PIDFILE -TERM $DAEMON_BIN
	rc_status -v
	;;
    restart)
	$0 stop
	$0 start
	rc_status
	;;
    force-reload)
	echo -n "Reload service $DAEMON"
	killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN
	rc_status -v
	;;
    reload)
	echo -n "Reload service $DAEMON"
	killproc -p $DAEMON_PIDFILE -HUP $DAEMON_BIN
	rc_status -v
	;;
    status)
	echo -n "Checking for $DAEMON: "
	checkproc -p $DAEMON_PIDFILE $DAEMON_BIN
	rc_status -v
	;;
    probe)
	test "$DAEMON_CONF" -nt "$DAEMON_PIDFILE" && echo reload
	;;
    try-restart|condrestart)
        if test "$1" = "condrestart"; then
            echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
        fi
        $0 status
        if test $? = 0; then
            $0 restart
        else
            rc_reset # Not running is not a failure.
        fi
        rc_status # Remember status and be quiet
        ;;
    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
	exit 1
	;;
esac
rc_exit
