#! /bin/sh
### BEGIN INIT INFO
# Provides:          xnbd xnbd-common
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: xNBD startup script
# Description:       start/stop xNBD services
### END INIT INFO

# Author: Arno Töll <debian@toell.net>
# This script is more or less just a SysV init cascade to call approrpiate
# commands on xnbd-register instead

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="xNBD network devices"
NAME="xnbd-register"
DAEMON=/usr/sbin/$NAME
SCRIPTNAME=/etc/init.d/$NAME

# This variable will be overwritten
DAEMON_OPTS=""

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

. /lib/lsb/init-functions

case "$1" in
  start|stop|status|restart|force-reload)
  	CMD=$1

	# Load kernel module
  	[ "$CMD" = start ] && modprobe nbd

	# Don't handle force-reload separetely
	[ "$CMD" = "force-reload" ] && CMD="restart"

	[ "$VERBOSE" = no ] && DAEMON_OPTS="--quiet"
	$DAEMON "--$CMD" $DAEMON_OPTS
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
	exit 3
	;;
esac

:
