slitaz-boot-scripts view etc/init.d/hwconf.sh @ rev 93

Allow to blacklist modules
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Wed May 28 14:23:50 2008 +0200 (2008-05-28)
parents f1f2677d464a
children 58cc6775e0f0
line source
1 #!/bin/sh
2 # /etc/init.d/hwconf.sh - SliTaz hardware autoconfiguration.
3 #
4 . /etc/init.d/rc.functions
6 # Restore sound config for installed system.
7 if [ -s /var/lib/sound-card-driver ]; then
8 echo -n "Restoring last alsa configuration..."
9 alsactl restore
10 status
11 fi
13 # Detect PCI devices and load kernel module only at first boot
14 # or in LiveCD mode.
15 if [ ! -s /var/lib/detected-modules ]; then
17 . /etc/rcS.conf
19 echo "Detecting PCI devices..."
20 MODULES_LIST=`lspci -k | grep "modules" | cut -d ":" -f 2 | sed s/-/_/g`
21 for mod in $MODULES_LIST
22 do
23 if ! `lsmod | grep -q "$mod"` && ! `echo $BLACKLIST_MODULES | grep -q "$mod"`; then
24 modname=`echo "$mod" | sed s/_/-/g`
25 echo "Loading Kernel modules: $modname"
26 detect="$detect $modname"
27 /sbin/modprobe $modname
28 fi
29 done
30 # yenta_socket = laptop
31 if `lsmod | grep -q "yenta_socket"`; then
32 detect="$detect ac battery"
33 modprobe ac
34 modprobe battery
35 fi
36 echo "$detect" > /var/lib/detected-modules
37 # Now add modules to rcS.conf
39 load=`echo "$LOAD_MODULES $detect" | sed s/" "/" "/g`
40 sed -i s/"LOAD_MODULES=\"$LOAD_MODULES\""/"LOAD_MODULES=\"$load\""/ \
41 /etc/rcS.conf
42 # Retry a network connection with DHCP.
43 if ifconfig -a | grep -q "eth0"; then
44 if [ ! -f /var/run/udhcpc.eth0.pid ]; then
45 echo "Starting udhcpc client on: eth0... "
46 /sbin/udhcpc -b -i eth0 -p /var/run/udhcpc.eth0.pid
47 fi
48 fi
49 fi
51 # Sound configuration stuff. First check if sound=no and remove all
52 # sound Kernel modules.
53 if grep -q "sound=" /proc/cmdline; then
54 DRIVER=`cat /proc/cmdline | sed 's/.*sound=\([^ ]*\).*/\1/'`
55 case "$DRIVER" in
56 no)
57 echo -n "Removing all sound kernel modules..."
58 rm -rf /lib/modules/`uname -r`/kernel/sound
59 status
60 echo -n "Removing all sound packages..."
61 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
62 pkg=${i#/var/lib/tazpkg/installed/}
63 echo 'y' | tazpkg remove ${pkg%/*} > /dev/null
64 done
65 for i in alsa-lib mhwaveedit asunder libcddb ; do
66 echo 'y' | tazpkg remove $i > /dev/null
67 done
68 status;;
69 noconf)
70 echo "Sound configuration is disable from cmdline...";;
71 *)
72 if [ -x /usr/sbin/soundconf ]; then
73 echo "Using sound kernel module $DRIVER..."
74 /usr/sbin/soundconf -M $DRIVER
75 fi;;
76 esac
77 # Sound card my already be detected by PCI-detect.
78 elif [ -d /proc/asound ]; then
79 cp /proc/asound/modules /var/lib/sound-card-driver
80 /usr/bin/amixer >/dev/null || /usr/sbin/soundconf
81 /usr/sbin/setmixer
82 # Start soundconf to config driver and load module for Live mode
83 # if not yet detected.
84 elif [ ! -s /var/lib/sound-card-driver ]; then
85 if [ -x /usr/sbin/soundconf ]; then
86 /usr/sbin/soundconf
87 else
88 echo "Unable to found: /usr/sbin/soundconf"
89 fi
90 fi
92 # Screen size config for slim/Xvesa (last config dialog befor login).
93 if [ ! -s /etc/X11/screen.conf -a -x /usr/bin/slim ]; then
94 # $HOME is not yet set.
95 HOME=/root
96 if grep -q "screen=*" /proc/cmdline; then
97 export NEW_SCREEN=`cat /proc/cmdline | sed 's/.*screen=\([^ ]*\).*/\1/'`
98 if [ "$NEW_SCREEN" = "text" ]; then
99 echo -n "Disabling X login manager: slim..."
100 sed -i s/'slim'/''/ /etc/rcS.conf
101 status
102 else
103 tazx `cat /etc/X11/wm.default`
104 fi
105 else
106 tazx `cat /etc/X11/wm.default`
107 fi
108 fi