#!/bin/sh # modprober by Linus Sphinx cut from start 4/11/2004 # menued interface to load modules off cdrom # 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 } driverslist() { if [ "$1" = "fs" ]; then pat=^/lib/modules/${KVER}/kernel/${1}/ else pat=^/lib/modules/${KVER}/kernel/drivers/${1}/ fi grep -E "${pat}" /lib/modules/${KVER}/modules.dep | while read g do set $g mod=`basename $1 .ko: | sed sG^/w+/GG` for d in $2 $3 $4 $5 $6 $7 $8 $9 do dep="$dep `basename $d .ko | sed sG^/w+/GG`" done if [ "$dep" = "" ]; then dep=none else dep=`echo $dep | sed sQ\ Q/Q` fi echo $mod ${dep# } $mod dep="" done } loadfsdrivers() { dialog --clear --separate-output --title "| available drivers |" --cancel-label "Back" --checklist \ "Install Module Dependents" 0 40 0 `driverslist ${1}` 2>/tmp/modz if [ -s /tmp/modz ]; then rm -f /tmp/modules /tmp/modlog cat /tmp/modz | while read b do todo=`grep /${b}.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 cd /lib/modules/${KVER} zcat $MODULESTGZ | tar x .${driver#/lib/modules/$KVER} 1>/tmp/modlog 2>/tmp/modlog echo "zcat $MODULESTGZ | tar x .${driver#/lib/modules/$KVER}" >> /tmp/log insmod ${driver} 1>/tmp/modlog 2>/tmp/modlog sleep 1 rm ${driver} 1>/tmp/modlog 2>/tmp/modlog lsmod >> /tmp/modlog done if [ -s /tmp/modlog ]; then dialog --title "| probe and load modules result |" --exit-label "close" --tailbox /tmp/modlog 0 0 fi rm -f /tmp/modlog done fi } modulemenu() { while true do exec 3>&1 modval=`dialog --clear --title "| available modules |" --ok-label "Go" --cancel-label "Back" --menu \ "Load the minimum required to recognize your target media and extra filesystem(s) to use ONLY. \ ext2, ext3 and xfs are already loaded" 0 0 0 \ "fs" "File Systems " \ "md" "Medial Distribution(raid) " \ "scsi" "SCSI Disk Controllers " \ "ide" "IDE Disk Controllers " \ "list" "List Modules Loaded " \ 2>&1 1>&3` modretval=$? exec 3>&- case $modretval in 0) if [ "$modval" = "list" ]; then dialog --title "| loaded modules |" --exit-label "close" --msgbox "`lsmod`" 0 0 else loadfsdrivers $modval fi ;; 1) echo "Exiting" return ;; esac done } 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 cd /lib/modules/${KVER} zcat $MODULESTGZ | tar x .${driver#/lib/modules/$KVER} 1>/tmp/modlog 2>/tmp/modlog echo "zcat $MODULESTGZ | tar x .${driver#/lib/modules/$KVER}" >> /tmp/log insmod ${driver} 1>/tmp/modlog 2>/tmp/modlog sleep 1 rm ${driver} 1>/tmp/modlog 2>/tmp/modlog lsmod >> /tmp/modlog done } mount | grep -q cdrom if [ "$?" = "1" ]; then findandmountgnnix fi if [ ! -f /lib/modules/${KVER}/modules.dep ]; then unpackmodulesdep fi if [ -z "$arg" ]; then modulemenu exit 0 else loadamod $arg fi