File netfpga.rkd.init of Package netfpga

#!/bin/sh
#
# /etc/init.d/netfpga.rkd
#   and its symbolic link
# /sbin/rcnetfpga.rkd
#
### BEGIN INIT INFO
# Provides:          netfpga.rkd
# Required-Start:    netfpga.cpci_reprogram $time $network $syslog $remote_fs
# Should-Start:      netfpga.rkd netfpga.cpci_reprogram
# Required-Stop:     $null
# Should-Stop:       $null
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# X-UnitedLinux-Default-Enabled: no
# Short-Description: Router Kit daemon
# Description:       Reprograms the NetFPGA with the reference router
#	and starts the router kit daemon to mirror linux routing state
#	into the NetFPGA.
### END INIT INFO

# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
RKD_BIN=/usr/bin/nf_rkd
test -x $RKD_BIN || { echo "$RKD_BIN not installed"; 
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

. /etc/rc.status

# Reset status of this service
rc_reset

case "$1" in
    start)
	echo -n "Starting Router Kit"
	/usr/bin/nf2_download /usr/share/netfpga/bitfiles/reference_router.bit
	if test $? != 0 ; then
		exit 1;
	fi

	## Start daemon with startproc(8). If this fails
	## the return value is set appropriately by startproc.
	/sbin/startproc $RKD_BIN

	# Remember status and be verbose
	rc_status -v
	;;
    stop)
	echo -n "Shutting down Router Kit"
	## Stop daemon with killproc(8) and if this fails
	## killproc sets the return value according to LSB.

	/sbin/killproc -TERM $RKD_BIN

	# Remember status and be verbose
	rc_status -v
	;;
    restart)
	## Stop the service and regardless of whether it was
	## running or not, start it again.
	$0 stop
	$0 start

	# Remember status and be quiet
	rc_status
	;;
    status)
	echo -n "Checking for service Router Kit "
	## Check status with checkproc(8), if process is running
	## checkproc will return with exit status 0.

	# Return value is slightly different for the status command:
	# 0 - service up and running
	# 1 - service dead, but /var/run/  pid  file exists
	# 2 - service dead, but /var/lock/ lock file exists
	# 3 - service not running (unused)
	# 4 - service status unknown :-(
	# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
	
	# NOTE: checkproc returns LSB compliant status values.
	/sbin/checkproc $RKD_BIN
	# NOTE: rc_status knows that we called this init script with
	# "status" option and adapts its messages accordingly.
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart}"
	exit 3
	;;
esac
rc_exit
openSUSE Build Service is sponsored by