#!/bin/sh
# Copyright (C) 2004 International Business Machines Corporation and others.
# All Rights Reserved. This program and the accompanying
# materials are made available under the terms of the
# Common Public License v1.0 which accompanies this distribution.
#
# Author: Brian King <brking@us.ibm.com>
#
# iprdump
#
# System startup script for the ipr dump facility
#
### BEGIN INIT INFO
# Provides: iprdump
# Required-Start:    $local_fs iprinit
# Should-Start:      $remote_fs $syslog
# Required-Stop:     $local_fs $syslog iprinit
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the ipr dump daemon
# Description:       Start the ipr dump daemon
### END INIT INFO

IPRDUMP=/sbin/iprdump
test -x $IPRDUMP || exit 5
. /lib/init/vars.sh
. /lib/lsb/init-functions

start() {
    if [ ! -d /sys/class/scsi_generic ] ; then
        modprobe sg
    fi
    start_daemon $IPRDUMP --daemon
}

stop() {
    killproc $IPRDUMP
}

status() {
    status_of_proc $IPRDUMP iprdump
}

case "$1" in
    start)
	if init_is_upstart; then exit 1; fi
	[ "$VERBOSE" = no ] || log_daemon_msg "Starting ipr dump daemon" iprdump
	start
	[ "$VERBOSE" = no ] || log_end_msg $?
	;;
    stop)
	if init_is_upstart; then exit 0; fi
	[ "$VERBOSE" = no ] || log_daemon_msg "Shutting down ipr dump daemon" iprdump
	stop
	[ "$VERBOSE" = no ] || log_end_msg $?
	;;
    restart|reload|force-reload)
	if init_is_upstart; then exit 1; fi
	[ "$VERBOSE" = no ] || log_daemon_msg "Restarting ipr dump daemon" iprdump
	stop && start
	[ "$VERBOSE" = no ] || log_end_msg $?
	;;
    status)
	if init_is_upstart; then exit 1; fi
	status
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart|reload}"
	exit 1
	;;
esac
