home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / etc / rc.d / rc.modules < prev    next >
Encoding:
Text File  |  2006-06-16  |  5.7 KB  |  176 lines

  1. #called from rc.sysinit
  2. #Puppy Linux 2006
  3.  
  4. #NOTE: edit rc.local for your custom setup (see README.txt)
  5.  
  6. #many modules already loaded by /sbin/init script in the initial ramdisk.
  7.  
  8. #if no match, or multiple matches, may need manual override...
  9. OVERRIDES='dmfe 0x00001282 0x00009102 #r_hughes reports tulip module not work.
  10. '
  11.  
  12. PCIINFO="`lspci -i /usr/share/pci-usb-pcmcia.ids`" #database in /usr/share/pci.ids.
  13. USBINFO="$PCIINFO"
  14. PCINUMS="`lspci -n | tr -s " " | cut -f 4 -d " " | tr "\n" " "`"
  15. CPUVER="`uname -r`"
  16. PCIMODINFO="`cat /lib/modules/$CPUVER/modules.pcimap | tr -s " " | cut -f 1-3 -d " "`"
  17.  
  18. #tempestuous suggested read this...
  19. [ ! "`grep -i "nopcmcia" /proc/cmdline`" = "" ] && FLAGNOPCMCIA="true" #see below.
  20.  
  21. #0.9.9 taken from rc.pcmcia...
  22. cleanup()
  23. {
  24.     while read SN CLASS MOD INST DEV EXTRA ; do
  25.     if [ "$SN" != "Socket" ] ; then
  26.         /etc/pcmcia/$CLASS stop $DEV 2> /dev/null
  27.     fi
  28.     done
  29. }
  30. #note, never create /var/lib/pcmcia/ directory, and pcmcia cardmgr will
  31. #default to using /var/run/.
  32.  
  33.  
  34. #load modules for usb (usually already done in initrd)...
  35. #PUPMODE=2, full h.d. install, will not have initrd, so repeat this code...
  36. if [ ! -f /initrd/sbin/init ];then
  37.  XPCINUMS="`lspci -n | cut -f 4 -d ' ' | tr "\n" '|'`"
  38.  EXECME="grep --extended-regexp \"$XPCINUMS\""
  39.  if [ ! "`echo "$USBINFO" | grep -i "usb"`" = "" ];then
  40.   #find reqd modules from usb database...
  41.   USBMODS="`$EXECME /usr/share/pci-usb.modules | cut -f 3 -d ':'`"
  42.   modprobe usbcore 2>/dev/null
  43.   if [ $? -eq 0 ];then
  44.    echo "Loading USB base driver modules..."
  45.    #k2.6 problem, weird, some computers need delay before loading uhci-hcd or ohci-hcd...
  46.    sleep 1 #not needed k2.4!!!
  47.    ##problem, some PCs need both uhci_hcd and ohci_hcd loaded...
  48.    #if [ ! "`echo "$USBINFO $USBMODS" | grep -i "uhci"`" = "" ];then
  49.    # modprobe uhci-hcd
  50.    # [ $? -eq 0 ] && USB="1"
  51.    #fi
  52.    #if [ ! "`echo "$USBINFO $USBMODS" | grep -i "ohci"`" = "" ];then
  53.    # modprobe ohci-hcd
  54.    # [ $? -eq 0 ] && USB="1"
  55.    #fi
  56.  
  57.    #v2.01 seems safe to always load both... but maybe try particular order...
  58.    [ ! "`echo "$USBINFO $USBMODS" | grep -i "uhci"`" = "" ] && modprobe uhci-hcd
  59.    [ ! "`echo "$USBINFO $USBMODS" | grep -i "ohci"`" = "" ] && modprobe ohci-hcd
  60.    [ "`lsmod | grep '^uhci'`" = "" ] && modprobe uhci-hcd
  61.    [ "`lsmod | grep '^ohci'`" = "" ] && modprobe ohci-hcd
  62.    [ ! "`lsmod | grep --extended-regexp '^uhci|^ohci'`" = "" ] && USB="1"
  63.  
  64.    if [ "$USB" = "1" ];then
  65.     if [ ! "`echo "$USBINFO $USBMODS" | grep -i --extended-regexp "usb2|usb 2|ehci"`" = "" ];then
  66.      #ehci-hcd needed in addition to one of the above...
  67.      modprobe ehci-hcd 2>/dev/null
  68.      [ $? -eq 0 ] && USB="2"
  69.     fi
  70.    fi
  71.   fi
  72.  fi
  73. fi
  74.  
  75.  
  76. #find modules to load, pci interfaces...
  77. CNTSND=0
  78. for ONENUM in $PCINUMS
  79. do
  80.  MODLDED="false"
  81.  FLAGIGNORE="false"
  82.  VENDOR="0x0000`echo -n "$ONENUM" | cut -f 1 -d ':'`"
  83.  DEVICE="0x0000`echo -n "$ONENUM" | cut -f 2 -d ':'`"
  84.  APATTERN="$VENDOR $DEVICE"
  85.  FNDMOD="`echo "$PCIMODINFO" | grep "$APATTERN" | head -n 1`"
  86.  
  87.  #need overrides in some cases...
  88.  REPLACEMENT="`echo "$OVERRIDES" | grep "$APATTERN"`"
  89.  [ ! "$REPLACEMENT" = "" ] && FNDMOD="$REPLACEMENT"
  90.   
  91.  if [ ! "$FNDMOD" = "" ];then
  92.   MODULE="`echo -n "$FNDMOD" | cut -f 1 -d " "`"
  93.   
  94.   #8139cp is buggy...
  95.   [ "$MODULE" = "8139cp" ] && MODULE="8139too"
  96.  
  97.   #may have to ignore pcmcia...
  98.   [ "$FLAGNOPCMCIA" = "true" ] && FLAGIGNORE="true"
  99.   if [ ! "$FLAGIGNORE" = "true" ];then
  100.    modprobe $MODULE 2> /dev/null
  101.    [ $? -eq 0 ] && MODLDED="true"
  102.   fi
  103.   if [ "$MODLDED" = "true" ];then
  104.    #if a sound module, setup alsa (rc.alsa is started in rc.local0)...
  105.    if [ ! "`echo -n "$MODULE" | grep '^snd\-'`" = "" ];then
  106.     DPATTERN="alias snd\\-card\\-$CNTSND"
  107.     if [ "`grep "$DPATTERN" /etc/modprobe.conf`" = "" ];then
  108.      echo "alias snd-card-$CNTSND $MODULE" >> /etc/modprobe.conf
  109.      echo "alias sound-slot-$CNTSND $MODULE" >> /etc/modprobe.conf
  110.     else
  111.      #for portability, check if correct sound card...
  112.      BPATTERN="alias snd\\-card\\-$CNTSND $MODULE"
  113.      if [ "`grep "$BPATTERN" /etc/modprobe.conf`" = "" ];then
  114.       grep -v "$DPATTERN" /etc/modprobe.conf > /tmp/modprobe.conf
  115.       cp -f /tmp/modprobe.conf /etc/modprobe.conf
  116.       echo "alias snd-card-$CNTSND $MODULE" >> /etc/modprobe.conf
  117.       echo "alias sound-slot-$CNTSND $MODULE" >> /etc/modprobe.conf
  118.      fi
  119.     fi
  120.     CNTSND=`expr $CNTSND + 1`
  121.    fi
  122.   fi
  123.  fi
  124. done
  125.  
  126.  
  127. #load module for pci-pcmcia bridge interfaces...
  128. #(above code block may have already loaded it)
  129. if [ ! "$FLAGNOPCMCIA" = "true" ];then
  130.  if [ ! "`echo "$PCIINFO" | grep -i --extended-regexp 'cardbus|pcmcia'`" = "" ];then
  131.   #find out if pcmcia drivers already loaded...
  132.   lsmod | grep "i82365"
  133.   if [ ! $? -eq 0 ];then #=0 found
  134.    lsmod | grep "tcic"
  135.    if [ ! $? -eq 0 ];then
  136.     lsmod | grep "yenta_socket"
  137.     if [ ! $? -eq 0 ];then
  138.      echo "Loading a pcmcia base module..."
  139.      /sbin/modprobe pcmcia_core 2> /dev/null #k2.6 does not have this.
  140.      /sbin/modprobe i82365 2> /dev/null
  141.      if [ ! $? -eq 0 ]; then # try tcic 
  142.       /sbin/modprobe tcic 2> /dev/null
  143.       if [ ! $? -eq 0 ]; then # try yenta_socket
  144.        /sbin/modprobe yenta_socket 2> /dev/null
  145.        if [ ! $? -eq 0 ];then
  146.         echo "FAILED TO LOAD A PCMCIA DRIVER MODULE!"
  147.         MPCMCIA="failed"
  148.        fi
  149.       fi
  150.      fi
  151.     fi
  152.    fi
  153.   fi
  154.   if [ ! "$MPCMCIA" = "failed" ];then
  155.    #ds.o is a needed base module...
  156.    modprobe ds 2> /dev/null #k2.6 does not have this.
  157.    #v0.9.9 do this if pcmcia_cs package installed...
  158.    if [ -f /sbin/cardmgr ];then
  159.     if [ -s /var/run/cardmgr.pid ];then
  160.      rm /var/run/cardmgr.pid
  161.     fi
  162.     if [ -r /var/run/stab ] ; then
  163.      cat /var/run/stab | cleanup
  164.     fi
  165.     echo "Running PCMCIA cardmgr program..."
  166.     /sbin/cardmgr
  167.     touch /var/lock/subsys/pcmcia 2>/dev/null
  168.    fi
  169.   fi
  170.  fi
  171. fi
  172.  
  173.  
  174.  
  175. ###END###
  176.