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

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