#!/bin/sh
#
# rc.gpib 0.01 2000/11/20 18:49:26 (Toshihiro Handa)
#
# This is designed to work in Linux kernel 2.0.35 init setups
# for GPIB board PCG4301 made by Interface (FBI) co. ltd. Japan.
#

usage()
{
    echo "Usage: $0 {start|stop|restart}"
}

EXITCODE=1
DRIVER_LOCATE=/usr/local/interface
KERNEL_VERSION=ver2035
for x in "1" ; do

    if [ $# -lt 1 ] ; then usage ; break ; fi
    action=$1

    case "$action" in

    'start')
	echo -n "GPIB drive:"
	if [ -f $DRIVER_LOCATE/gpg4301/drivers/$KERNEL_VERSION/cp4301.o ] ; then
		/sbin/insmod $DRIVER_LOCATE/gpg4301/drivers/$KERNEL_VERSION/cp4301.o
		echo " installed"
	else
		echo " module $DRIVER_LOCATE/gpg4301/drivers/$KERNEL_VERSION/cp4301.o not found."
		break
	fi
	;;

    'stop')
	echo -n "Shutting down GPIB module:"
	if fgrep -q "cp4301  " /proc/modules ; then
	    /sbin/rmmod cp4301
	    echo -n " removed"
	fi
	echo "."
	EXITCODE=0
	;;

    'restart')
	$0 stop
	$0 start
	EXITCODE=0
	;;

    *)
	usage
	;;

    esac

done

# Only exit if we're in our own subshell
if [ "${0##*/}" = "rc.gpib" ] ; then
    exit $EXITCODE
fi
