#!/bin/sh # module probulater by Linus Sphinx 1/3/2004 # bridges the compressed modules for hotplug # Copyright (c) 2004 Linus Sphinx # Part of the gn*nix conspiracy http://gnnix.org # uncompress the module and insert it and it's deps # MTPT=/mnt/cdrom KVER=`uname -r` MODULESTGZ=${MTPT}/tool/modules.tgz CDROM= export MTPT KVER MODULESTGZ CDROM bail=0 retval=0 arg=${1} findandmountgnnix() { find /proc/ide -name media -print | while read i do grep -q cdrom $i if [ "$?" -eq "0" ]; then olifs=$IFS IFS=/ set $i IFS=$olifs mount -t iso9660 -r /dev/${5} $MTPT if [ -f $MODULESTGZ ]; then CDROM=/dev/${5} else umount $MTPT fi fi done } unpackmodulesdep() { if [ -f $MODULESTGZ ]; then cd /lib/modules/${KVER} zcat $MODULESTGZ | tar x ./modules.* if [ ! -f /lib/modules/${KVER}/modules.dep ]; then exit 1 fi fi } loadamod() { todo=`grep /${1}.ko: /lib/modules/$KVER/modules.dep | sed sQ:QQ` set $todo echo "$9 $8 $7 $6 $5 $4 $3 $2 $1" | sort | uniq | while read driver do if [ ! -z ${driver} ]; then cd /lib/modules/${KVER} zcat $MODULESTGZ | tar x .${driver#/lib/modules/$KVER} insmod ${driver} sleep 1 rm ${driver} fi done } mount | grep -q cdrom if [ "$?" = "1" ]; then findandmountgnnix fi if [ ! -f /lib/modules/${KVER}/modules.dep ]; then unpackmodulesdep fi if [ ! -z "$arg" ]; then loadamod $arg fi