#!/bin/bash
#
#	/etc/init.d/lin_tape
#
# (C) Copyright International Business Machines Corp., 2011-2012
#	lin_tape: Device Driver for IBM Tape Storage
#	This script loads/unloads the module and manages the
#       daemon associated with the driver
#
# chkconfig:   235 20 80
# description: Driver and daemon for IBM tape storage systems
# config:      /etc/lin_taped.conf
#
### BEGIN INIT INFO
# Provides:      lin_tape
# Required-Start: $null
# Required-Stop: $null
# Should-Start:  hwscan
# Should-Stop:  $null
# Default-Start: 2 3 5
# Default-Stop:  0 1 6
# Description:   Driver and daemon for IBM tape storage systems
### END INIT INFO

# Source function library.
[ -x /etc/init.d/functions ] && . /etc/init.d/functions

start() {
	echo -n "Starting lin_tape: "
	modprobe lin_tape
	RETVAL=$?
	[ $RETVAL -eq 0 ] && [ -x /usr/bin/lin_taped ] && /usr/bin/lin_taped start
	RETVAL=$RETVAL||$?
	
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/lin_tape
	echo
	return $RETVAL
}	

stop() {
	echo -n "Shutting down lin_tape: "
	[ -x /usr/bin/lin_taped ] && /usr/bin/lin_taped stop
	RETVAL=$?
	RETVAL=$RETVAL||$?
	rm -f /var/lock/subsys/lin_tape
	echo
	return $RETVAL
}

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    status)
	[ `lsmod | grep -q lin_tape` ] && echo "lin_tape.ko present"
	[ -x /usr/bin/lin_taped ] && /usr/bin/lin_taped status || :
	;;
    restart|reload)
    	stop
	start
	;;
    condrestart)
	[ -f /var/lock/subsys/lin_tape ] && $0 restart || :
	;;
    *)
	echo "Usage: $0 {start|stop|status|reload|restart|condrestart}"
	exit 1

esac

exit $?
#
