updatenetmoduleslist.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/bash
  2. #Barry Kauler 2009
  3. #w001 now in /usr/sbin in the distro, called from /etc/rc.d/rc.update.
  4. #w474 bugfix for 2.6.29 kernel, modules.dep different format.
  5. #w478 old k2.6.18.1 has madwifi modules (ath_pci.ko) in /lib/modules/2.6.18.1/net.
  6. #v423 now using busybox depmod, which generates modules.dep in "old" format.
  7. #111027 make modinfo quiet.
  8. #120507 improve kernel version test. add 'sdio' interfaces.
  9. KERNVER="`uname -r`"
  10. KERNSUBVER=`echo -n $KERNVER | cut -f 3 -d '.' | cut -f 1 -d '-'` #29
  11. KERNMAJVER=`echo -n $KERNVER | cut -f 2 -d '.'` #6
  12. DRIVERSDIR="/lib/modules/$KERNVER/kernel/drivers/net"
  13. echo "Updating /etc/networkmodules..."
  14. DEPFORMAT='new'
  15. if vercmp $KERNVER lt 2.6.29; then #120507
  16. DEPFORMAT='old'
  17. fi
  18. #v423 need better test, as now using busybox depmod...
  19. [ "`grep '^/lib/modules' /lib/modules/${KERNVER}/modules.dep`" != "" ] && DEPFORMAT='old'
  20. if [ "$DEPFORMAT" = "old" ];then
  21. OFFICIALLIST="`cat /lib/modules/${KERNVER}/modules.dep | grep "^/lib/modules/$KERNVER/kernel/drivers/net/" | sed -e 's/\.gz:/:/' | cut -f 1 -d ':'`"
  22. else
  23. OFFICIALLIST="`cat /lib/modules/${KERNVER}/modules.dep | grep "^kernel/drivers/net/" | sed -e 's/\.gz:/:/' | cut -f 1 -d ':'`"
  24. fi
  25. #there are a few extra scattered around... needs to be manually updated...
  26. EXTRALIST="extra/acx.ko
  27. extra/rt2400.ko
  28. extra/rt2500.ko
  29. extra/rt2570.ko
  30. extra/rt61.ko
  31. extra/rt73.ko
  32. extra/acx-mac80211.ko
  33. extra/atl2.ko
  34. extra/rt2860sta.ko
  35. extra/rt2870sta.ko
  36. madwifi/ath_pci.ko
  37. net/ath_pci.ko
  38. linux-wlan-ng/prism2_usb.ko
  39. linux-wlan-ng/prism2_pci.ko
  40. linux-wlan-ng/prism2_plx.ko
  41. r8180/r8180.ko
  42. "
  43. RAWLIST="$OFFICIALLIST
  44. $EXTRALIST"
  45. #the list has to be cutdown to genuine network interfaces only...
  46. echo -n "" > /tmp/networkmodules
  47. echo "$RAWLIST" |
  48. while read ONERAW
  49. do
  50. [ "$ONERAW" = "" ] && continue #precaution
  51. ONEBASE="`basename $ONERAW .ko`"
  52. modprobe -vn $ONEBASE >/dev/null 2>&1
  53. ONEINFO="`modinfo $ONEBASE 2>/dev/null | tr '\t' ' ' | tr -s ' '`" #111027 make it quiet.
  54. ONETYPE="`echo "$ONEINFO" | grep '^alias:' | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d ':'`"
  55. ONEDESCR="`echo "$ONEINFO" | grep '^description:' | head -n 1 | cut -f 2 -d ':'`"
  56. if [ "$ONETYPE" = "pci" -o "$ONETYPE" = "pcmcia" -o "$ONETYPE" = "usb" ];then
  57. echo "Adding $ONEBASE"
  58. echo -e "$ONEBASE \"$ONETYPE: $ONEDESCR\"" >> /tmp/networkmodules
  59. fi
  60. #v408 add b43legacy.ko...
  61. if [ "$ONETYPE" = "ssb" ];then
  62. echo "Adding $ONEBASE"
  63. echo -e "$ONEBASE \"$ONETYPE: $ONEDESCR\"" >> /tmp/networkmodules
  64. fi
  65. #120507 add sdio interfaces...
  66. if [ "$ONETYPE" = "sdio" ];then
  67. echo "Adding $ONEBASE"
  68. echo -e "$ONEBASE \"$ONETYPE: $ONEDESCR\"" >> /tmp/networkmodules
  69. fi
  70. done
  71. sort -u /tmp/networkmodules > /etc/networkmodules
  72. ###end###