home *** CD-ROM | disk | FTP | other *** search
- #called from rc.sysinit
- #Puppy Linux 2006
-
- #NOTE: edit rc.local for your custom setup (see README.txt)
-
- #many modules already loaded by /sbin/init script in the initial ramdisk.
-
- #if no match, or multiple matches, may need manual override...
- OVERRIDES='dmfe 0x00001282 0x00009102 #r_hughes reports tulip module not work.
- '
-
- PCIINFO="`lspci -i /usr/share/pci-usb-pcmcia.ids`" #database in /usr/share/pci.ids.
- USBINFO="$PCIINFO"
- PCINUMS="`lspci -n | tr -s " " | cut -f 4 -d " " | tr "\n" " "`"
- CPUVER="`uname -r`"
- PCIMODINFO="`cat /lib/modules/$CPUVER/modules.pcimap | tr -s " " | cut -f 1-3 -d " "`"
-
- #tempestuous suggested read this...
- [ ! "`grep -i "nopcmcia" /proc/cmdline`" = "" ] && FLAGNOPCMCIA="true" #see below.
-
- #0.9.9 taken from rc.pcmcia...
- cleanup()
- {
- while read SN CLASS MOD INST DEV EXTRA ; do
- if [ "$SN" != "Socket" ] ; then
- /etc/pcmcia/$CLASS stop $DEV 2> /dev/null
- fi
- done
- }
- #note, never create /var/lib/pcmcia/ directory, and pcmcia cardmgr will
- #default to using /var/run/.
-
-
- #load modules for usb (usually already done in initrd)...
- #PUPMODE=2, full h.d. install, will not have initrd, so repeat this code...
- if [ ! -f /initrd/sbin/init ];then
- XPCINUMS="`lspci -n | cut -f 4 -d ' ' | tr "\n" '|'`"
- EXECME="grep --extended-regexp \"$XPCINUMS\""
- if [ ! "`echo "$USBINFO" | grep -i "usb"`" = "" ];then
- #find reqd modules from usb database...
- USBMODS="`$EXECME /usr/share/pci-usb.modules | cut -f 3 -d ':'`"
- modprobe usbcore 2>/dev/null
- if [ $? -eq 0 ];then
- echo "Loading USB base driver modules..."
- #k2.6 problem, weird, some computers need delay before loading uhci-hcd or ohci-hcd...
- sleep 1 #not needed k2.4!!!
- ##problem, some PCs need both uhci_hcd and ohci_hcd loaded...
- #if [ ! "`echo "$USBINFO $USBMODS" | grep -i "uhci"`" = "" ];then
- # modprobe uhci-hcd
- # [ $? -eq 0 ] && USB="1"
- #fi
- #if [ ! "`echo "$USBINFO $USBMODS" | grep -i "ohci"`" = "" ];then
- # modprobe ohci-hcd
- # [ $? -eq 0 ] && USB="1"
- #fi
-
- #v2.01 seems safe to always load both... but maybe try particular order...
- [ ! "`echo "$USBINFO $USBMODS" | grep -i "uhci"`" = "" ] && modprobe uhci-hcd
- [ ! "`echo "$USBINFO $USBMODS" | grep -i "ohci"`" = "" ] && modprobe ohci-hcd
- [ "`lsmod | grep '^uhci'`" = "" ] && modprobe uhci-hcd
- [ "`lsmod | grep '^ohci'`" = "" ] && modprobe ohci-hcd
- [ ! "`lsmod | grep --extended-regexp '^uhci|^ohci'`" = "" ] && USB="1"
-
- if [ "$USB" = "1" ];then
- if [ ! "`echo "$USBINFO $USBMODS" | grep -i --extended-regexp "usb2|usb 2|ehci"`" = "" ];then
- #ehci-hcd needed in addition to one of the above...
- modprobe ehci-hcd 2>/dev/null
- [ $? -eq 0 ] && USB="2"
- fi
- fi
- fi
- fi
- fi
-
-
- #find modules to load, pci interfaces...
- CNTSND=0
- for ONENUM in $PCINUMS
- do
- MODLDED="false"
- FLAGIGNORE="false"
- VENDOR="0x0000`echo -n "$ONENUM" | cut -f 1 -d ':'`"
- DEVICE="0x0000`echo -n "$ONENUM" | cut -f 2 -d ':'`"
- APATTERN="$VENDOR $DEVICE"
- FNDMOD="`echo "$PCIMODINFO" | grep "$APATTERN" | head -n 1`"
-
- #need overrides in some cases...
- REPLACEMENT="`echo "$OVERRIDES" | grep "$APATTERN"`"
- [ ! "$REPLACEMENT" = "" ] && FNDMOD="$REPLACEMENT"
-
- if [ ! "$FNDMOD" = "" ];then
- MODULE="`echo -n "$FNDMOD" | cut -f 1 -d " "`"
-
- #8139cp is buggy...
- [ "$MODULE" = "8139cp" ] && MODULE="8139too"
-
- #may have to ignore pcmcia...
- [ "$FLAGNOPCMCIA" = "true" ] && FLAGIGNORE="true"
- if [ ! "$FLAGIGNORE" = "true" ];then
- modprobe $MODULE 2> /dev/null
- [ $? -eq 0 ] && MODLDED="true"
- fi
- if [ "$MODLDED" = "true" ];then
- #if a sound module, setup alsa (rc.alsa is started in rc.local0)...
- if [ ! "`echo -n "$MODULE" | grep '^snd\-'`" = "" ];then
- DPATTERN="alias snd\\-card\\-$CNTSND"
- if [ "`grep "$DPATTERN" /etc/modprobe.conf`" = "" ];then
- echo "alias snd-card-$CNTSND $MODULE" >> /etc/modprobe.conf
- echo "alias sound-slot-$CNTSND $MODULE" >> /etc/modprobe.conf
- else
- #for portability, check if correct sound card...
- BPATTERN="alias snd\\-card\\-$CNTSND $MODULE"
- if [ "`grep "$BPATTERN" /etc/modprobe.conf`" = "" ];then
- grep -v "$DPATTERN" /etc/modprobe.conf > /tmp/modprobe.conf
- cp -f /tmp/modprobe.conf /etc/modprobe.conf
- echo "alias snd-card-$CNTSND $MODULE" >> /etc/modprobe.conf
- echo "alias sound-slot-$CNTSND $MODULE" >> /etc/modprobe.conf
- fi
- fi
- CNTSND=`expr $CNTSND + 1`
- fi
- fi
- fi
- done
-
-
- #load module for pci-pcmcia bridge interfaces...
- #(above code block may have already loaded it)
- if [ ! "$FLAGNOPCMCIA" = "true" ];then
- if [ ! "`echo "$PCIINFO" | grep -i --extended-regexp 'cardbus|pcmcia'`" = "" ];then
- #find out if pcmcia drivers already loaded...
- lsmod | grep "i82365"
- if [ ! $? -eq 0 ];then #=0 found
- lsmod | grep "tcic"
- if [ ! $? -eq 0 ];then
- lsmod | grep "yenta_socket"
- if [ ! $? -eq 0 ];then
- echo "Loading a pcmcia base module..."
- /sbin/modprobe pcmcia_core 2> /dev/null #k2.6 does not have this.
- /sbin/modprobe i82365 2> /dev/null
- if [ ! $? -eq 0 ]; then # try tcic
- /sbin/modprobe tcic 2> /dev/null
- if [ ! $? -eq 0 ]; then # try yenta_socket
- /sbin/modprobe yenta_socket 2> /dev/null
- if [ ! $? -eq 0 ];then
- echo "FAILED TO LOAD A PCMCIA DRIVER MODULE!"
- MPCMCIA="failed"
- fi
- fi
- fi
- fi
- fi
- fi
- if [ ! "$MPCMCIA" = "failed" ];then
- #ds.o is a needed base module...
- modprobe ds 2> /dev/null #k2.6 does not have this.
- #v0.9.9 do this if pcmcia_cs package installed...
- if [ -f /sbin/cardmgr ];then
- if [ -s /var/run/cardmgr.pid ];then
- rm /var/run/cardmgr.pid
- fi
- if [ -r /var/run/stab ] ; then
- cat /var/run/stab | cleanup
- fi
- echo "Running PCMCIA cardmgr program..."
- /sbin/cardmgr
- touch /var/lock/subsys/pcmcia 2>/dev/null
- fi
- fi
- fi
- fi
-
-
-
- ###END###
-