slitaz-boot-scripts view etc/init.d/system.sh @ rev 262

Improve, fixes, big changes, 2 scripts less, one new system.sh, GUI config in live tha work with latest cookutils packages, well tested on Qemu, frugal, first HD install boot
author Christophe Lincoln <pankso@slitaz.org>
date Mon May 16 00:32:16 2011 +0200 (2011-05-16)
parents
children 8b16caf41633
line source
1 #!/bin/sh
2 # /etc/init.d/system.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. It also configure
6 # system language, keyboarf and TZ in live mode.
7 #
8 . /etc/init.d/rc.functions
10 # Parse cmdline args for boot options (See also rcS and bootopts.sh).
11 XARG=""
12 for opt in $(cat /proc/cmdline)
13 do
14 case $opt in
15 sound=*)
16 DRIVER=${opt#sound=} ;;
17 xarg=*)
18 XARG="$XARG ${opt#xarg=}" ;;
19 screen=text)
20 SCREEN=text
21 # Disable X.
22 echo -n "Disabling X login manager: slim..."
23 . /etc/rcS.conf
24 RUN_DAEMONS=$(echo $RUN_DAEMONS | sed s/' slim'/''/)
25 sed -i s/"RUN_DAEMONS.*"/"RUN_DAEMONS=\"$RUN_DAEMONS\"/" /etc/rcS.conf
26 status ;;
27 screen=*)
28 SCREEN=${opt#screen=} ;;
29 *)
30 continue ;;
31 esac
32 done
34 # Sound configuration stuff. First check if sound=no and remove all
35 # sound Kernel modules.
36 if [ -n "$DRIVER" ]; then
37 case "$DRIVER" in
38 no)
39 echo -n "Removing all sound kernel modules..."
40 rm -rf /lib/modules/`uname -r`/kernel/sound
41 status
42 echo -n "Removing all sound packages..."
43 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
44 pkg=${i#/var/lib/tazpkg/installed/}
45 echo 'y' | tazpkg remove ${pkg%/*} > /dev/null
46 done
47 for i in alsa-lib mhwaveedit asunder libcddb ; do
48 echo 'y' | tazpkg remove $i > /dev/null
49 done
50 status ;;
51 noconf)
52 echo "Sound configuration was disabled from cmdline..." ;;
53 *)
54 if [ -x /usr/sbin/soundconf ]; then
55 echo "Using sound kernel module $DRIVER..."
56 /usr/sbin/soundconf -M $DRIVER
57 fi ;;
58 esac
59 # Sound card may already be detected by PCI-detect.
60 elif [ -d /proc/asound ]; then
61 # Restore sound config for installed system.
62 if [ -s /etc/asound.state ]; then
63 echo -n "Restoring last alsa configuration..."
64 alsactl restore
65 status
66 else
67 /usr/sbin/setmixer
68 fi
69 # Start soundconf to config driver and load module for Live mode
70 # if not yet detected.
71 /usr/bin/amixer >/dev/null || /usr/sbin/soundconf
72 else
73 echo "Unable to configure sound card."
74 fi
76 # Start TazPanel
77 [ -x /usr/bin/tazpanel ] && tazpanel start
79 # Auto recharge packages list (after network connection of course)
80 [ "$RECHARGE_PACKAGES_LIST" == "yes" ] && tazpkg recharge &
82 # Locale config. Do a gui config for both lang/keymap.
83 echo "Checking if /etc/locale.conf exists... "
84 if [ ! -s "/etc/locale.conf" ]; then
85 if [ "$SCREEN" != "text" ] && [ -x /usr/bin/Xorg ]; then
86 echo "GUI configuration starting..."
87 DISPLAY=:1 tazbox boot
88 else
89 tazlocale
90 fi
91 else
92 echo -n "Locale configuration: $(cat /etc/locale.conf)" && status
93 fi
95 # Keymap config.
96 if [ -s "/etc/keymap.conf" ]; then
97 KEYMAP=$(cat /etc/keymap.conf)
98 echo "Keymap configuration: $KEYMAP"
99 if [ -x /bin/loadkeys ]; then
100 loadkeys $KEYMAP
101 else
102 loadkmap < /usr/share/kmap/$KEYMAP.kmap
103 fi
104 else
105 tazkeymap
106 fi
108 # Timezone config. Set timezone using the keymap config for fr, be, fr_CH
109 # and ca with Montreal.
110 if [ ! -s "/etc/TZ" ]; then
111 map=$(cat /etc/keymap.conf)
112 case "$map" in
113 fr-latin1|be-latin1)
114 echo "Europe/Paris" > /etc/TZ ;;
115 fr_CH-latin1|de_CH-latin1)
116 echo "Europe/Zurich" > /etc/TZ ;;
117 cf)
118 echo "America/Montreal" > /etc/TZ ;;
119 *)
120 echo "UTC" > /etc/TZ ;;
121 esac
122 fi
124 # Xorg auto configuration.
125 if [ "$SCREEN" != "text" -a ! -s /etc/X11/xorg.conf -a -x /usr/bin/Xorg ]; then
126 echo "Configuring Xorg..."
127 # $HOME is not yet set.
128 HOME=/root
129 sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf
130 sed -i s/"^xserver_arguments"/'\#xserver_arguments'/ /etc/slim.conf
131 tazx config-xorg 2>/var/log/xorg.configure.log
132 fi
134 # Start X sesssion as soon as possible in Live/frugal mode. HD install
135 # can use FAST_BOOT_X wich start X even before. In live mode we need
136 # keymap config for Xorg configuration and a working Xorg config.
137 if [ "$SCREEN" != "text" ] && [ -x /usr/bin/slim ]; then
138 if fgrep -q root=/dev/null /proc/cmdline; then
139 /etc/init.d/slim start
140 fi
141 fi
143 # Firefox hack to get the right locale.
144 if fgrep -q "fr_" /etc/locale.conf; then
145 # But is the fox installed ?
146 if [ -f "/var/lib/tazpkg/installed/firefox/receipt" ]; then
147 . /var/lib/tazpkg/installed/firefox/receipt
148 sed -i 's/en-US/fr/' /etc/firefox/pref/firefox-l10n.js
149 fi
150 fi