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

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