| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # Steven Shiau <[email protected]> |
| 3 | # License: GPL |
| 4 | |
| 5 | # Description: hwscan can not load the chip module (like piix)... So here we |
| 6 | # use the results scanned from hwscan, then load them. |
| 7 | # Ref: http://lists.suse.com/archive/suse-linux-e/2005-Aug/0782.html |
| 8 | |
| 9 | # For SuSE |
| 10 | ### BEGIN INIT INFO |
| 11 | # Provides: parse-load-mod-suse |
| 12 | # Required-Start: hwscan boot.coldplug |
| 13 | # Should-Start: |
| 14 | # Required-Stop: |
| 15 | # Default-Start: B |
| 16 | # Default-Stop: |
| 17 | # Description: Load all the modules scanned by hwscan. |
| 18 | ### END INIT INFO |
| 19 | |
| 20 | parse_and_load_modulesscip-shell shell shell-project 0.0.0 parse_and_load_modules().() { |
| 21 | MOD_MAP=/lib/modules/`unamescip-shell system . . uname. -r`/modules.pcimap |
| 22 | pcitable_hwdata="/usr/lib/mkpxeinitrd-net/initrd-skel/etc/pcitablescip-shell filesystem . . `/usr/lib/mkpxeinitrd-net/initrd-skel/etc/pcitable`." |
| 23 | mod_list="" |
| 24 | echoscip-shell system . . echo. -n "Mapping the modules from the results of hwscan and lspci if available..." |
| 25 | # Part 1: use the hwscan results |
| 26 | for ihw in /var/lib/hardware/unique-keys/*; do |
| 27 | echoscip-shell system . . echo. -n "." |
| 28 | if [scip-shell system . . `[`. -e "$ihw" ]; then |
| 29 | MOD_TMP="$(mktempscip-shell system . . mktemp. /tmp/mod.XXXXXXscip-shell filesystem . . `/tmp/mod.XXXXXX`.)" |
| 30 | grepscip-shell system . . grep. -E "(^VendorID=|^DeviceID=|^SubVendorID=|^SubDeviceID=)" $ihw > $MOD_TMP |
| 31 | . $MOD_TMP |
| 32 | map_mod="$(grepscip-shell system . . grep. "0x0000${VendorID} 0x0000${DeviceID}" $MOD_MAP | sortscip-shell system . . sort. | uniqscip-shell system . . uniq. | cutscip-shell system . . cut. -d" " -f1)" |
| 33 | for im in $map_mod; do |
| 34 | [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. "$mod_list" | grepscip-shell system . . grep. $im 2>/dev/nullscip-shell filesystem . . `/dev/null`.)" ] && mod_list="$mod_list $im" |
| 35 | done |
| 36 | [scip-shell system . . `[`. -f "$MOD_TMP" ] && rmscip-shell system . . rm. -f $MOD_TMP |
| 37 | fi |
| 38 | done |
| 39 | echoscip-shell system . . echo. "done!" |
| 40 | # Part 2: since only PCI devices are in modules.pcimap, for SCSI or others, we |
| 41 | # need to use other method. Borrow the hwdata from RedHat. |
| 42 | if [scip-shell system . . `[`. -x /usr/lib/mkpxeinitrd-net/initrd-skel/sbin/scan_pciscip-shell filesystem . . `/usr/lib/mkpxeinitrd-net/initrd-skel/sbin/scan_pci`. ]; then |
| 43 | mod2_list="$(/usr/lib/mkpxeinitrd-net/initrd-skel/sbin/scan_pciscip-shell filesystem . . `/usr/lib/mkpxeinitrd-net/initrd-skel/sbin/scan_pci`. /usr/lib/mkpxeinitrd-net/initrd-skel/etcscip-shell filesystem . . `/usr/lib/mkpxeinitrd-net/initrd-skel/etc`.)" |
| 44 | mod_list="$mod_list $mod2_list" |
| 45 | fi |
| 46 | [scip-shell system . . `[`. -n "$mod_list" ] && echoscip-shell system . . echo. "The modules to be loaded: $mod_list" |
| 47 | for imod in $mod_list; do |
| 48 | imod_aform="$(echoscip-shell system . . echo. $imod | sedscip-shell system . . sed. -e "s/-/_/g")" |
| 49 | if [scip-shell system . . `[`. -z "$(lsmod | grepscip-shell system . . grep. "^$imod_aform")" ]; then |
| 50 | echoscip-shell system . . echo. -n "Loading $imod..." |
| 51 | modprobe $imod |
| 52 | echoscip-shell system . . echo. "done!" |
| 53 | else |
| 54 | echoscip-shell system . . echo. "$imod is already loaded, skip this!" |
| 55 | fi |
| 56 | done |
| 57 | } |
| 58 | |
| 59 | case "$1" in |
| 60 | start) |
| 61 | parse_and_load_modulesscip-shell shell shell-project 0.0.0 parse_and_load_modules(). |
| 62 | ;; |
| 63 | stop) |
| 64 | # do nothing. |
| 65 | truescip-shell system . . true. |
| 66 | ;; |
| 67 | *) |
| 68 | echoscip-shell system . . echo. "Usage: $0 start" >&2 |
| 69 | exit 1 |
| 70 | ;; |
| 71 | esac |