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

hwconf.sh: tiny changes to keep compatible with tazx.
author Antoine Bodin <gokhlayeh@mailoo.org>
date Mon Jul 05 12:56:24 2010 +0200 (2010-07-05)
parents 3c447e4af92c
children 36546e2a0d3a
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 sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf
80 sed -i s/"^xserver_arguments"/'\#xserver_arguments'/ /etc/slim.conf
81 tazx config-xorg
82 fi
84 # Screen size config for slim/Xvesa (last config dialog before login).
85 #
86 # NOTE: Xvesa is unmaintained, package will be removed and all related
87 # code cleaned
88 #
89 if [ ! -s /etc/X11/screen.conf -a -x /usr/bin/Xvesa ]; then
90 # $HOME is not yet set.
91 HOME=/root
92 if [ -n "$XARG" ]; then
93 # Add an extra argument to xserver_arguments (xarg=-2button)
94 sed -i "s| -screen|$XARG -screen|" /etc/slim.conf
95 fi
96 if [ -n "$SCREEN" ]; then
97 case "$SCREEN" in
98 text)
99 # Disable X.
100 echo -n "Disabling X login manager: slim..."
101 . /etc/rcS.conf
102 RUN_DAEMONS=`echo $RUN_DAEMONS | sed s/' slim'/''/`
103 sed -i s/"RUN_DAEMONS.*"/"RUN_DAEMONS=\"$RUN_DAEMONS\"/" /etc/rcS.conf
104 status ;;
105 auto)
106 # Auto detect screen resolution.
107 export NEW_SCREEN=`Xvesa -listmodes 2>&1 | grep ^0x | \
108 awk '{ printf "%s %s\n",$2 }' \
109 | sort -nr | grep x[1-2][4-6] | head -n 1`
110 tazx `cat /etc/X11/wm.default` ;;
111 1024x600*|800x480*)
112 set -- $(echo $SCREEN | sed 's/x/ /g')
113 915resolution -l 2>/dev/null | \
114 grep " ${1}x" | awk -v h=$1 -v v=$2 \
115 'END {system("915resolution " $2 " " h " " v)}'
116 # Use specified screen resolution.
117 export NEW_SCREEN=$SCREEN
118 tazx `cat /etc/X11/wm.default` ;;
119 *)
120 # Use specified screen resolution.
121 export NEW_SCREEN=$SCREEN
122 tazx `cat /etc/X11/wm.default` ;;
123 esac
124 else
125 tazx `cat /etc/X11/wm.default`
126 fi
127 fi