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

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