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

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