#! /bin/sh

# modules list
mods="scsi_mod si3124r5"


# Rebuild InitrdModules -
#  . Add all modules from $mods that are loaded currently
#  . Put modules in correct order

imods=`grep "InitrdModules:" /etc/install.inf | sed -e 's/^InitrdModules://'`
imods2=" $imods $mods "

# Add all modules that are loaded currently
for i in `cat /proc/modules | cut -d ' ' -f 1` ; do
  x="${imods2/ $i / }"
  if [ "$imods2" != "$x" ] ; then
    imods2="$x"
    imods3="$i $imods3"
  fi
done

# Add all modules that were in InitrdModules, but are not loaded currently 
for i in $mods ; do
  imods2="${imods2/ $i / }"
done
imods3="$imods3 $imods2"

imods=`echo $imods3`

grep -v "InitrdModules:" /etc/install.inf >/etc/install.tmp

if [ x"$imods" != x"" ] ; then
  echo "InitrdModules: $imods" >/etc/install.initrd
  cat /etc/install.initrd /etc/install.tmp > /etc/install.inf
  rm -f /etc/install.initrd /etc/install.tmp
else
  mv /etc/install.tmp /etc/install.inf
fi

sed -e '//s//si3124r5/' /lib/modules/2.6.5-7.244-default/modules.pcimap >/tmp/modules.pcimap
mv /tmp/modules.pcimap /lib/modules/2.6.5-7.244-default/modules.pcimap

