blob: 88bf3103e683b0ae5098924f15cf9171dd829b39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
#! /bin/sh
# Autodetection script for scanning /sys for hardware
# for Archlinux by Tobias Powalowski <tpowa@archlinux.org>
usage () {
echo "$0 [options]"
echo ""
echo " This is a tool that detects/lists modules that are exported by /sys"
echo ""
echo " Options:"
echo " -load-modules load all detected modules"
echo " -show-modules show all detected modules"
echo " -show-agp show AGP modules"
echo " -show-ide show IDE modules"
echo " -show-scsi show SCSI modules"
echo " -show-sata show SATA modules"
echo " -show-usb show USB modules"
echo " -show-fw show FIREWIRE modules"
echo " -show-net show NETWORK modules"
echo " -show-isdn show ISDN modules"
echo " -show-pcmcia show PCMCIA modules"
echo " -show-sound show SOUND modules"
echo " -show-video show VIDEO modules"
echo " -show-other show OTHER modules"
echo ""
echo " For /etc/mkinitrd.conf use:"
echo " -ide show detected HOSTCONTROLLER_IDE"
echo " -scsi show detected HOSTCONTROLLER_SCSI"
echo " -sata show detected HOSTCONTROLLER_SATA"
echo " -usb show detected HOSTCONTROLER_USB"
echo ""
exit 1
}
[ "$1" == "" ] && usage
: >/tmp/modules-plain
: >/tmp/modules-sorted
: >/tmp/moduleslist
: >/tmp/modprobe
: >/tmp/modules
# find pci aliases
find /sys/devices/ -name "modalias" > /tmp/modules
# get the modaliases
for i in `cat /tmp/modules`; do
cat $i >> /tmp/modprobe
done
# generate files for the different actions
for i in `cat /tmp/modprobe`; do
modprobe -i --show-depends $i >> /tmp/modules-plain 2>/dev/null
done
# fix evdev detection
if [ `grep "serio:ty06pr*[id]*[ex]*" /tmp/modprobe` ]; then
modprobe -i --show-depends evdev >> /tmp/modules-plain 2>/dev/null
fi
# fix Intel536ep detection
if [ `grep "pci:v00008086d00001040sv000016BEsd00001040bc07sc80i00" /tmp/modprobe` ]; then
modprobe -i --show-depends Intel536 >> /tmp/modules-plain 2>/dev/null
fi
# find PNP devices, like parports, soundcards etc. workaround for rtc,pcspkr,irtty-sir and analog included
for i in `find /sys -name "id*" | grep pnp`; do
devid=`cat $i | grep PNP`
modprobe -i --show-depends pnp:d${devid} >> /tmp/modules-plain 2>/dev/null
if [ "$devid" == "PNP0800" ]; then
modprobe -i --show-depends pcspkr >> /tmp/modules-plain 2>/dev/null
fi
if [ "$devid" == "PNP0b00" ]; then
modprobe -i --show-depends rtc >> /tmp/modules-plain 2>/dev/null
fi
if [ "$devid" == "PNP0510" ]; then
modprobe -i --show-depends irtty-sir >> /tmp/modules-plain 2>/dev/null
fi
if [ "$devid" == "PNP0511" ]; then
modprobe -i --show-depends irtty-sir >> /tmp/modules-plain 2>/dev/null
fi
if [ "$devid" == "PNPb02f" ]; then
modprobe -i --show-depends analog >> /tmp/modules-plain 2>/dev/null
fi
# load ppp-generic if serial ports are detected for modems
if [ "$devid" == "PNP0501" ]; then
modprobe -i --show-depends ppp-generic >> /tmp/modules-plain 2>/dev/null
fi
done
sort -u /tmp/modules-plain >> /tmp/modules-sorted
sed -ne "s#^insmod.*/\(.*\)\.ko.*#\1#p" /tmp/modules-sorted >> /tmp/moduleslist
# delete modules that are blacklisted
for i in $BLACKLIST; do
[ "$i" ] || continue
sed -i -e "/^$i$/d" /tmp/moduleslist
done
listmods() {
key=$1 ; shift
ex=
while [ "$1" ]; do
[ "$ex" ] && ex="$ex|$1" || ex="$1"
shift
done
for ln in `grep "$key" /tmp/modules-sorted | sed 's|^insmod ||g'`; do
if [ "$ex" ]; then
echo $ln | egrep -v "$ex" | sed -ne "s#^/.*/\(.*\)\.ko.*#\1#p"
else
echo $ln | sed -ne "s#^/.*/\(.*\)\.ko.*#\1#p"
fi
done
}
showlist() {
cat=$1 ; shift
[ $# -gt 0 ] || return
echo -n "$cat: "
for i in $*; do echo -n "$i "; done
echo ""
}
# starting different actions
while [ $# -gt 0 ]; do
case $1 in
-load-modules)
# load all detected pci modules
for i in `cat /tmp/moduleslist`; do
modprobe $i > /dev/null 2>&1
done
;;
-show-modules)
showlist "AGP " `listmods agp/`
showlist "IDE " `listmods ide/`
showlist "SCSI " `listmods scsi/ sata ata_piix libata`
showlist "SATA " `listmods ata eata`
showlist "USB " `listmods usb/`
showlist "FW " `listmods ieee1394/`
showlist "NET " `listmods net/`
showlist "ISDN " `listmods isdn/`
showlist "PCMCIA" `listmods pcmcia/`
showlist "SOUND " `listmods sound/`
showlist "VIDEO " `listmods video/`
showlist "OTHER " `listmods modules/ agp/ ide/ scsi/ sata usb/ ieee1394 net/ isdn/ pcmcia/ sound/ video/`
;;
-show-agp) showlist "AGP " `listmods agp/` ;;
-show-ide) showlist "IDE " `listmods ide/` ;;
-show-scsi) showlist "SCSI " `listmods scsi/ sata ata_piix libata` ;;
-show-sata) showlist "SATA " `listmods ata eata` ;;
-show-usb) showlist "USB " `listmods usb/` ;;
-show-fw) showlist "FW " `listmods ieee1394/` ;;
-show-net) showlist "NET " `listmods net/` ;;
-show-isdn) showlist "ISDN " `listmods isdn/` ;;
-show-pcmcia) showlist "PCMCIA" `listmods pcmcia/` ;;
-show-sound) showlist "SOUND " `listmods sound/` ;;
-show-video) showlist "VIDEO " `listmods video/` ;;
-show-other) showlist "OTHER " `listmods .ko agp/ ide/ scsi/ sata usb/ ieee1394 net/ isdn/ pcmcia/ sound/ video/` ;;
-ide) showlist "HOSTCONTROLLER_IDE" `listmods ide/pci` ;;
-scsi) showlist "HOSTCONTROLLER_SCSI" `listmods scsi/ sata ata_piix libata` ;;
-sata) showlist "HOSTCONTROLLER_SATA" `listmods ata eata libata` ;;
-usb) showlist "HOSTCONTROLLER_USB" `listmods usb/host` "" ;;
esac
shift
done
# cleanup
rm /tmp/{modules-plain,modules-sorted,moduleslist,modprobe,modules}
# vim: set ts=2 sw=2:
|