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

Tiny fix for hwconf.sh
author Christophe Lincoln <pankso@slitaz.org>
date Tue Feb 17 21:40:18 2009 +0100 (2009-02-17)
parents 5d620cd96aee
children d3bf7f751e5f
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 # We need module_name to match output of lsmod.
20 echo "Detecting PCI devices..."
21 MODULES_LIST=`lspci -k | grep "modules" | cut -d ":" -f 2 | sed s/-/_/g`
22 for mod in $MODULES_LIST
23 do
24 if ! lsmod | grep -q "$mod" && [ -f "$(modprobe -l $mod)" ]; then
25 echo "Loading Kernel modules: $mod"
26 detect="$detect $mod"
27 /sbin/modprobe $mod
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 sed -i 's/= cpu/= batt\n}\n\nPlugin {\n type = cpu/' \
36 /etc/lxpanel/default/panels/panel 2> /dev/null
37 fi
38 echo "$detect" > /var/lib/detected-modules
39 # Now add modules to rcS.conf
40 load=`echo "$LOAD_MODULES $detect" | sed s/" "/" "/g`
41 sed -i s/"LOAD_MODULES=\"$LOAD_MODULES\""/"LOAD_MODULES=\"$load\""/ \
42 /etc/rcS.conf
43 # Retry a network connection with DHCP.
44 if ifconfig -a | grep -q "eth0"; then
45 if [ ! -f /var/run/udhcpc.eth0.pid ]; then
46 echo "Starting udhcpc client on: eth0... "
47 /sbin/udhcpc -b -i eth0 -p /var/run/udhcpc.eth0.pid
48 fi
49 fi
50 fi
52 # Sound configuration stuff. First check if sound=no and remove all
53 # sound Kernel modules.
54 if grep -q "sound=" /proc/cmdline; then
55 DRIVER=`cat /proc/cmdline | sed 's/.*sound=\([^ ]*\).*/\1/'`
56 case "$DRIVER" in
57 no)
58 echo -n "Removing all sound kernel modules..."
59 rm -rf /lib/modules/`uname -r`/kernel/sound
60 status
61 echo -n "Removing all sound packages..."
62 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
63 pkg=${i#/var/lib/tazpkg/installed/}
64 echo 'y' | tazpkg remove ${pkg%/*} > /dev/null
65 done
66 for i in alsa-lib mhwaveedit asunder libcddb ; do
67 echo 'y' | tazpkg remove $i > /dev/null
68 done
69 status;;
70 noconf)
71 echo "Sound configuration was disabled from cmdline...";;
72 *)
73 if [ -x /usr/sbin/soundconf ]; then
74 echo "Using sound kernel module $DRIVER..."
75 /usr/sbin/soundconf -M $DRIVER
76 fi;;
77 esac
78 # Sound card may already be detected by PCI-detect.
79 elif [ -d /proc/asound ]; then
80 cp /proc/asound/modules /var/lib/sound-card-driver
81 /usr/bin/amixer >/dev/null || /usr/sbin/soundconf
82 /usr/sbin/setmixer
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