#!/bin/bash

# Source function library.
. /etc/init.d/functions

RETVAL=0

start_daemon() {
	[ -f /sbin/$1 ] || return
	echo -n $"Starting $1: "
	daemon /sbin/$1 $2
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$1
	return $RETVAL
}

stop_daemon() {
	[ -f /sbin/$1 ] || return
	echo -n $"Stopping $1: "
	killproc /sbin/$1 
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$1
	return $RETVAL
}	

start_driver() {
	action $"Inserting $1.o" sh /opt/compaq/cpqci/cp$1 start
}

stop_driver() {
	action $"Removing $1.o" sh /opt/compaq/cpqci/cp$1 stop
}	

# See how we were called.
case "$1" in
  start)
	start_driver cpqci
	start_daemon cpqriisd -F
	;;
  stop)
	stop_daemon cpqriisd
	stop_driver cpqci
	;;
  restart)
	stop_daemon cpqriisd
	stop_driver cpqci
	start_driver cpqci
	start_daemon cpqriisd -F
	;;
  status|reload)
	# do not do anything; this is unreasonable
	:
	;;
  *)
	# do not advertise unreasonable commands that there is no reason
	# to use with this device
	echo "Usage: random {start|stop|status|restart|reload}"
	exit 1
esac

exit 0
