slitaz-modular view core/overlay/etc/init.d/hwconf.sh @ rev 27

Updated core profile. Added local-mirror script. Local-mirror will allow one to use the hg repos on slitaz to make a local network of slitaz.org.
author Christopher Rogers <slaxemulator@gmail.com>
date Wed Feb 23 05:03:35 2011 +0000 (2011-02-23)
parents
children
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 if [ "$SCREEN" != "noxconf" ]; then
83 tazx config-xorg
84 fi
85 fi
87 # Screen size config for slim/Xvesa (last config dialog before login).
88 #
89 # NOTE: Xvesa is unmaintained, package will be removed and all related
90 # code cleaned
91 #
92 if [ "$SCREEN" != "text" -a ! -s /etc/X11/screen.conf -a -x /usr/bin/Xvesa ]; then
93 # $HOME is not yet set.
94 HOME=/root
95 if [ -n "$XARG" ]; then
96 # Add an extra argument to xserver_arguments (xarg=-2button)
97 sed -i "s| -screen|$XARG -screen|" /etc/slim.conf
98 fi
99 if [ -n "$SCREEN" ]; then
100 case "$SCREEN" in
101 text)
102 # Disable X.
103 echo -n "Disabling X login manager: slim..."
104 . /etc/rcS.conf
105 RUN_DAEMONS=`echo $RUN_DAEMONS | sed s/' slim'/''/`
106 sed -i s/"RUN_DAEMONS.*"/"RUN_DAEMONS=\"$RUN_DAEMONS\"/" /etc/rcS.conf
107 status ;;
108 auto)
109 # Auto detect screen resolution.
110 export NEW_SCREEN=`Xvesa -listmodes 2>&1 | grep ^0x | \
111 awk '{ printf "%s %s\n",$2 }' \
112 | sort -nr | grep x[1-2][4-6] | head -n 1`
113 tazx `cat /etc/X11/wm.default` ;;
114 1024x600*|800x480*)
115 set -- $(echo $SCREEN | sed 's/x/ /g')
116 915resolution -l 2>/dev/null | \
117 grep " ${1}x" | awk -v h=$1 -v v=$2 \
118 'END {system("915resolution " $2 " " h " " v)}'
119 # Use specified screen resolution.
120 export NEW_SCREEN=$SCREEN
121 tazx `cat /etc/X11/wm.default` ;;
122 *)
123 # Use specified screen resolution.
124 export NEW_SCREEN=$SCREEN
125 tazx `cat /etc/X11/wm.default` ;;
126 esac
127 else
128 tazx `cat /etc/X11/wm.default`
129 fi
130 fi