#!/bin/bash
#
#/*******************************************************************
# * This file is part of the Emulex Linux Device Driver for         *
# * Fibre Channel Host Bus Adapters.                                *
# * Refer to the README file included with this package for         *
# * driver version and adapter support.                             *
# * Copyright (C) 2003-2005 Emulex.  All rights reserved.           *
# * www.emulex.com                                                  *
# *                                                                 *
# * This program is free software; you can redistribute it and/or   *
# * modify it under the terms of the GNU General Public License     *
# * as published by the Free Software Foundation; either version 2  *
# * of the License, or (at your option) any later version.          *
# *                                                                 *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of  *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   *
# * GNU General Public License for more details, a copy of which    *
# * can be found in the file COPYING included with this package.    *
# *******************************************************************/
######################################################################
#
# Startup script for the Emulex lpfcdfc driver.
# $Id: pkg/elxlpfc 1.2 2005/05/03 11:22:22EDT jsullivan Exp  $
#
# Red Hat header
# chkconfig: 2345 00 99
# description:  Loads or unloads the Emulex lpfcdfc
#               driver.
#
# SuSE header
### BEGIN INIT INFO
# Provides: elxlpfc
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Load lpfcdfc driver.
# Description: Loads or unloads the Emulex lpfcdfc driver.
### END INIT INFO

# Source function library.
if [ -s /etc/rc.config ]; then
    . /etc/rc.config
fi

if [ -s /etc/rc.status ]; then
    . /etc/rc.status
    rc_reset
    DISTRIBUTION=suse
elif [ -s /etc/rc.d/init.d/functions ]; then
    . /etc/rc.d/init.d/functions
    DISTRIBUTION=redhat
fi

DRIVER=lpfcdfc

RETVAL=0

start() {
        MESSAGE="Starting Emulex DFC driver: "
        if [ ${DISTRIBUTION} = "suse" ]; then
	    echo -n "${MESSAGE}"
	    /sbin/modprobe ${DRIVER}
	    rc_status -v
	else
	    action $"${MESSAGE}" /sbin/modprobe ${DRIVER}
	fi
	RETVAL=$?
	return $RETVAL
}

stop() {
        MESSAGE="Stopping Emulex DFC driver: "
	if [ ${DISTRIBUTION} = "suse" ]; then
	    echo -n "${MESSAGE}"
	    /sbin/rmmod ${DRIVER}
	    rc_status -v
	else
	    action $"${MESSAGE}" /sbin/rmmod ${DRIVER}
	fi
	RETVAL=$?
	return $RETVAL
}

case "$1" in
 start)
	start
        ;;
 stop)
	stop
        ;;
 restart)
	stop
	start
	;;
 *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
        ;;
esac

exit $RETVAL
