#! /bin/sh
### BEGIN INIT INFO
# Provides:        seldev
# Required-Start:  mmcdev
# Required-Stop:
# Default-Start:   3 4 5
# Default-Stop:
# Description: HP SEL module provides access to System Event Log in /proc.
### END INIT INFO
 
# Source function library.
. /etc/rc.config
. /etc/rc.status
 
# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}
 
# Force execution if not called by a runlevel directory.
test $link = $base && INSMOD_SELDEV="yes"
test "$INSMOD_SELDEV" = yes || exit 0
 

SEL_MODULE_PATH=char/mmc/era/shared/seldev/linux/seldev.o
PATH_MODIFIER=""
KERNEL=$(uname -r)
 
if [ "$(uname -r | grep -E "^2.2")" = "" ]; then
  PATH_MODIFIER=kernel/drivers
fi

#
#       See how we were called.
#
rc_reset
case "$1" in
  start)
    if [ "$(grep seldev /proc/devices)" = "" ]; then
	   echo -n 'Loading HP SEL device driver: '	
       /sbin/insmod -f /lib/modules/$KERNEL/$PATH_MODIFIER/$SEL_MODULE_PATH
       rc_status -v
    fi
	;;
  stop)
	echo -n 'Unloading HP SEL device driver: '
	rmmod seldev
	rc_status -v
	;;
  reload|restart)
	$0 stop
	$0 start
	rc_status
	;;
  *)
	echo "Usage: /etc/init.d/seldev {start|stop|restart|reload}"
	exit 1
esac
 
rc_exit