slitaz-boot-scripts rev 76
hwconf.sh: autodetect PCI device and load module if needed and avalaible
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Mon May 05 23:10:15 2008 +0200 (2008-05-05) |
parents | 1ba89cc0b7bc |
children | 90f1e1e131a1 |
files | etc/init.d/hwconf.sh |
line diff
1.1 --- a/etc/init.d/hwconf.sh Mon May 05 23:08:57 2008 +0200 1.2 +++ b/etc/init.d/hwconf.sh Mon May 05 23:10:15 2008 +0200 1.3 @@ -3,12 +3,48 @@ 1.4 # 1.5 . /etc/init.d/rc.functions 1.6 1.7 -# $HOME is not yet set. 1.8 -HOME=/root 1.9 +# Restore sound config for installed system. 1.10 +if [ -f /var/lib/sound-card-driver ]; then 1.11 + echo -n "Restoring last alsa configuration..." 1.12 + alsactl restore 1.13 + status 1.14 +fi 1.15 1.16 -# Sound configuration stuff. First check if sound=no and remoce all sound 1.17 -# Kernel modules. 1.18 -# 1.19 +# Detect PCI devices and load kernel module only at first boot 1.20 +# or in LiveCD mode. 1.21 +if [ ! -f /var/lib/detected-modules ]; then 1.22 + echo "Detecting PCI devices..." 1.23 + MODULES_LIST=`lspci -k | grep "modules" | cut -d ":" -f 2 | sed s/-/_/g` 1.24 + for mod in $MODULES_LIST 1.25 + do 1.26 + if ! `lsmod | grep -q "$mod"`; then 1.27 + modname=`echo "$mod" | sed s/_/-/g` 1.28 + echo "Loading Kernel modules: $modname" 1.29 + detect="$detect $modname" 1.30 + /sbin/modprobe $modname 1.31 + fi 1.32 + done 1.33 + # yenta_socket = laptop 1.34 + if `lsmod | grep -q "yenta_socket"`; then 1.35 + detect="$detect ac battery" 1.36 + modprobe ac 1.37 + modprobe battery 1.38 + fi 1.39 + echo "$detect" > /var/lib/detected-modules 1.40 + # Now add modules to rcS.conf 1.41 + . /etc/rcS.conf 1.42 + load=`echo "$LOAD_MODULES $detect" | sed s/" "/" "/g` 1.43 + sed -i s/"LOAD_MODULES=\"$LOAD_MODULES\""/"LOAD_MODULES=\"$load\""/ \ 1.44 + /etc/rcS.conf 1.45 + # Retry a network connection with DHCP. 1.46 + if ! `ifconfig -a | grep -q "eth0"`; then 1.47 + echo "Starting udhcpc client on: eth0... " 1.48 + /sbin/udhcpc -b -i eth0 -p /var/run/udhcpc.eth0.pid 1.49 + fi 1.50 +fi 1.51 + 1.52 +# Sound configuration stuff. First check if sound=no and remove all 1.53 +# sound Kernel modules. 1.54 if grep -q "sound=" /proc/cmdline; then 1.55 DRIVER=`cat /proc/cmdline | sed 's/.*sound=\([^ ]*\).*/\1/'` 1.56 case "$DRIVER" in 1.57 @@ -33,32 +69,24 @@ 1.58 /usr/sbin/soundconf -M $DRIVER 1.59 fi;; 1.60 esac 1.61 +# Sound card my already be detected by PCI-detect. 1.62 +elif [ -d /proc/asound ]; then 1.63 + cp /proc/asound/modules /var/lib/sound-card-driver 1.64 + /usr/bin/setmixer 1.65 +# Start soundconf to config driver and load module for Live mode 1.66 +# if not yet detected. 1.67 elif [ ! -f /var/lib/sound-card-driver ]; then 1.68 if [ -x /usr/sbin/soundconf ]; then 1.69 - # Start soundconf to config driver and load module for Live mode 1.70 /usr/sbin/soundconf 1.71 else 1.72 echo "Unable to found: /usr/sbin/soundconf" 1.73 fi 1.74 fi 1.75 1.76 -# Restore sound config for installed system. 1.77 -if [ -f /var/lib/sound-card-driver ]; then 1.78 - echo -n "Restoring last alsa configuration..." 1.79 - alsactl restore 1.80 - status 1.81 -else 1.82 - # Remove LXpanel volumealsa if no sound configuration. 1.83 - if [ -f /etc/lxpanel/default/config ]; then 1.84 - sed -i s/'volumealsa'/'space'/ /etc/lxpanel/default/config 1.85 - fi 1.86 - if [ -f /etc/lxpanel/openbox/config ]; then 1.87 - sed -i s/'volumealsa'/'space'/ /etc/lxpanel/openbox/config 1.88 - fi 1.89 -fi 1.90 - 1.91 -# Screen size config for slim/Xvesa. 1.92 +# Screen size config for slim/Xvesa (last config dialog befor login). 1.93 if [ ! -f /etc/X11/screen.conf -a -x /usr/bin/slim ]; then 1.94 + # $HOME is not yet set. 1.95 + HOME=/root 1.96 if grep -q "screen=*" /proc/cmdline; then 1.97 export NEW_SCREEN=`cat /proc/cmdline | sed 's/.*screen=\([^ ]*\).*/\1/'` 1.98 if [ "$NEW_SCREEN" = "text" ]; then