#!/bin/bash
#
# mmcdev init script for mmcdev module
#
# chkconfig: 345 98 01
# description: HP MMC module provides access to HP's MMC.

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

test -x /usr/hpserver/bin/mmcdev_load || exit 0
test -x /usr/hpserver/bin/mmcdev_unload || exit 0

RETVAL=0

#
#	See how we were called.
#
case "$1" in
  start)
	# Check if mmcdev is already running
	if [ ! -f /var/lock/subsys/mmcdev ]; then
		echo -n 'Loading HP MMC device module: '
		/usr/hpserver/bin/mmcdev_load
	    RETVAL=$?
	    if [ $RETVAL -eq 0 ]; then
			touch /var/lock/subsys/mmcdev
			echo_success
		else
			echo_failure
		fi
	fi
	echo
	;;
  stop)
	echo -n 'Unloading HP MMC device module: '
	/usr/hpserver/bin/mmcdev_unload
	RETVAL=$?
	if [ $RETVAL -eq 0 ]; then
		echo_success
	else
		echo_failure
	fi
	rm -f /var/lock/subsys/mmcdev
	echo
	;;
  reload|restart)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  *)
	echo "Usage: /etc/rc.d/init.d/mmcdev {start|stop|restart|reload}"
	exit 1
esac

exit $RETVAL
