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

hwconf.sh: add support for Xorg autoconfig
author Christophe Lincoln <pankso@slitaz.org>
date Mon Jan 04 23:34:50 2010 +0100 (2010-01-04)
parents ddd1db038d3b
children 50b48a25519f
line source
1 #!/bin/sh
2 # /etc/init.d/hwconf.sh - SliTaz hardware configuration.
3 #
4 # This script configures the sound card and screen. Tazhw is used earlier
5 # at boot time to autoconfigure PCI and USB devices.
6 #
7 . /etc/init.d/rc.functions
9 # Parse cmdline args for boot options (See also rcS and bootopts.sh).
10 XARG=""
11 for opt in `cat /proc/cmdline`
12 do
13 case $opt in
14 sound=*)
15 DRIVER=${opt#sound=} ;;
16 xarg=*)
17 XARG="$XARG ${opt#xarg=}" ;;
18 screen=text)
19 # Disable X.
20 echo -n "Disabling X login manager: slim..."
21 . /etc/rcS.conf
22 RUN_DAEMONS=`echo $RUN_DAEMONS | sed s/' slim'/''/`
23 sed -i s/"RUN_DAEMONS.*"/"RUN_DAEMONS=\"$RUN_DAEMONS\"/" /etc/rcS.conf
24 status ;;
25 screen=*)
26 SCREEN=${opt#screen=} ;;
27 *)
28 continue ;;
29 esac
30 done
32 # Sound configuration stuff. First check if sound=no and remove all
33 # sound Kernel modules.
34 if [ -n "$DRIVER" ]; then
35 case "$DRIVER" in
36 no)
37 echo -n "Removing all sound kernel modules..."
38 rm -rf /lib/modules/`uname -r`/kernel/sound
39 status
40 echo -n "Removing all sound packages..."
41 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
42 pkg=${i#/var/lib/tazpkg/installed/}
43 echo 'y' | tazpkg remove ${pkg%/*} > /dev/null
44 done
45 for i in alsa-lib mhwaveedit asunder libcddb ; do
46 echo 'y' | tazpkg remove $i > /dev/null
47 done
48 status ;;
49 noconf)
50 echo "Sound configuration was disabled from cmdline..." ;;
51 *)
52 if [ -x /usr/sbin/soundconf ]; then
53 echo "Using sound kernel module $DRIVER..."
54 /usr/sbin/soundconf -M $DRIVER
55 fi ;;
56 esac
57 # Sound card may already be detected by PCI-detect.
58 elif [ -d /proc/asound ]; then
59 # Restore sound config for installed system.
60 if [ -s /etc/asound.state ]; then
61 echo -n "Restoring last alsa configuration..."
62 alsactl restore
63 status
64 else
65 /usr/sbin/setmixer
66 fi
67 # Start soundconf to config driver and load module for Live mode
68 # if not yet detected.
69 /usr/bin/amixer >/dev/null || /usr/sbin/soundconf
70 else
71 echo "Unable to configure sound card."
72 fi
74 # Xorg auto configuration.
75 if [ ! -s /etc/X11/xorg.conf -a -x /usr/bin/Xorg ]; then
76 echo "Configuring Xorg..."
77 # $HOME is not yet set.
78 HOME=/root
79 Xorg -configure
80 mv -f /root/xorg.conf.new /etc/X11/xorg.conf
81 sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf
82 sed -i s/"^xserver_arguments"/'\#xserver_arguments'/ /etc/slim.conf
83 tazx config-xorg
84 fi
86 # Screen size config for slim/Xvesa (last config dialog before login).
87 #
88 # NOTE: Xvesa is unmaintained, package will be removed and all related
89 # code cleaned
90 #
91 if [ ! -s /etc/X11/screen.conf -a -x /usr/bin/Xvesa ]; then
92 # $HOME is not yet set.
93 HOME=/root
94 if [ -n "$XARG" ]; then
95 # Add an extra argument to xserver_arguments (xarg=-2button)
96 sed -i "s| -screen|$XARG -screen|" /etc/slim.conf
97 fi
98 if [ -n "$SCREEN" ]; then
99 case "$SCREEN" in
100 text)
101 # Disable X.
102 echo -n "Disabling X login manager: slim..."
103 . /etc/rcS.conf
104 RUN_DAEMONS=`echo $RUN_DAEMONS | sed s/' slim'/''/`
105 sed -i s/"RUN_DAEMONS.*"/"RUN_DAEMONS=\"$RUN_DAEMONS\"/" /etc/rcS.conf
106 status ;;
107 auto)
108 # Auto detect screen resolution.
109 export NEW_SCREEN=`Xvesa -listmodes 2>&1 | grep ^0x | \
110 awk '{ printf "%s %s\n",$2 }' \
111 | sort -nr | grep x[1-2][4-6] | head -n 1`
112 tazx `cat /etc/X11/wm.default` ;;
113 1024x600*|800x480*)
114 set -- $(echo $SCREEN | sed 's/x/ /g')
115 915resolution -l 2>/dev/null | \
116 grep " ${1}x" | awk -v h=$1 -v v=$2 \
117 'END {system("915resolution " $2 " " h " " v)}'
118 # Use specified screen resolution.
119 export NEW_SCREEN=$SCREEN
120 tazx `cat /etc/X11/wm.default` ;;
121 *)
122 # Use specified screen resolution.
123 export NEW_SCREEN=$SCREEN
124 tazx `cat /etc/X11/wm.default` ;;
125 esac
126 else
127 tazx `cat /etc/X11/wm.default`
128 fi
129 fi