#!/bin/bash

RUNLEVEL=S
PROVIDES=modules
NEEDS="+root_fs"
RECOMMENDED=yes

. /etc/init.d/smgl_init
. /etc/sysconfig/modutils

test -x /sbin/depmod    || exit 5
test -x /sbin/modprobe  || exit 5

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

# Handle start action

if  [[  -x  /sbin/depmod  ]] && [[ "$PERFORM_DEPMOD" = "y" ]] ;  then
  if [[ "$ENABLE_SWAP_BEFORE_DEPMOD" = "y" ]] ; then
    echo "Enabling swap..."
    loadproc swapon -a
  fi
  echo  "Running depmod..."
  loadproc depmod  -a
fi

if [[ -e /etc/modules ]] && [[ -x /sbin/modprobe ]] ; then
  ( cat  /etc/modules;  builtin echo ) |
  while  read  MODULE ARGS;  do
    case  $MODULE in
      \#*|"")  continue  ;;
    esac
    echo "Loading module $MODULE..."
    loadproc modprobe  $MODULE  $ARGS
  done
fi
