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

hwconf.sh: check module exists during PCI detection
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Oct 23 20:54:35 2008 +0000 (2008-10-23)
parents 58cc6775e0f0
children d3d07a6cb5fe
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 if [ -n "$(modprobe -l $modname") ]; then
26 echo "Loading Kernel modules: $modname"
27 detect="$detect $modname"
28 /sbin/modprobe $modname
29 fi
30 fi
31 done
32 # yenta_socket = laptop
33 if `lsmod | grep -q "yenta_socket"`; then
34 detect="$detect ac battery"
35 modprobe ac
36 modprobe battery
37 fi
38 echo "$detect" > /var/lib/detected-modules
39 # Now add modules to rcS.conf
41 load=`echo "$LOAD_MODULES $detect" | sed s/" "/" "/g`
42 sed -i s/"LOAD_MODULES=\"$LOAD_MODULES\""/"LOAD_MODULES=\"$load\""/ \
43 /etc/rcS.conf
44 # Retry a network connection with DHCP.
45 if ifconfig -a | grep -q "eth0"; then
46 if [ ! -f /var/run/udhcpc.eth0.pid ]; then
47 echo "Starting udhcpc client on: eth0... "
48 /sbin/udhcpc -b -i eth0 -p /var/run/udhcpc.eth0.pid
49 fi
50 fi
51 fi
53 # Sound configuration stuff. First check if sound=no and remove all
54 # sound Kernel modules.
55 if grep -q "sound=" /proc/cmdline; then
56 DRIVER=`cat /proc/cmdline | sed 's/.*sound=\([^ ]*\).*/\1/'`
57 case "$DRIVER" in
58 no)
59 echo -n "Removing all sound kernel modules..."
60 rm -rf /lib/modules/`uname -r`/kernel/sound
61 status
62 echo -n "Removing all sound packages..."
63 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
64 pkg=${i#/var/lib/tazpkg/installed/}
65 echo 'y' | tazpkg remove ${pkg%/*} > /dev/null
66 done
67 for i in alsa-lib mhwaveedit asunder libcddb ; do
68 echo 'y' | tazpkg remove $i > /dev/null
69 done
70 status;;
71 noconf)
72 echo "Sound configuration was disabled from cmdline...";;
73 *)
74 if [ -x /usr/sbin/soundconf ]; then
75 echo "Using sound kernel module $DRIVER..."
76 /usr/sbin/soundconf -M $DRIVER
77 fi;;
78 esac
79 # Sound card may already be detected by PCI-detect.
80 elif [ -d /proc/asound ]; then
81 cp /proc/asound/modules /var/lib/sound-card-driver
82 /usr/bin/amixer >/dev/null || /usr/sbin/soundconf
83 /usr/sbin/setmixer
84 # Start soundconf to config driver and load module for Live mode
85 # if not yet detected.
86 elif [ ! -s /var/lib/sound-card-driver ]; then
87 if [ -x /usr/sbin/soundconf ]; then
88 /usr/sbin/soundconf
89 else
90 echo "Unable to find: /usr/sbin/soundconf"
91 fi
92 fi
94 # Screen size config for slim/Xvesa (last config dialog before login).
95 if [ ! -s /etc/X11/screen.conf -a -x /usr/bin/slim ]; then
96 # $HOME is not yet set.
97 HOME=/root
98 if grep -q "screen=*" /proc/cmdline; then
99 export NEW_SCREEN=`cat /proc/cmdline | sed 's/.*screen=\([^ ]*\).*/\1/'`
100 if [ "$NEW_SCREEN" = "text" ]; then
101 echo -n "Disabling X login manager: slim..."
102 sed -i s/'slim'/''/ /etc/rcS.conf
103 status
104 else
105 tazx `cat /etc/X11/wm.default`
106 fi
107 else
108 tazx `cat /etc/X11/wm.default`
109 fi
110 fi