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

Use new tazlocale and tazkeymap functions
author Christophe Lincoln <pankso@slitaz.org>
date Wed May 02 00:04:50 2012 +0200 (2012-05-02)
parents 8cc80e0d7d4e
children 175315b7699d
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 configures
6 # system language, keyboard 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 console=*)
16 sed -i "s/tty1/${opt#console=}/g;/^tty[2-9]::/d" \
17 /etc/inittab ;;
18 sound=*)
19 DRIVER=${opt#sound=} ;;
20 xarg=*)
21 XARG="$XARG ${opt#xarg=}" ;;
22 screen=text)
23 SCREEN=text
24 # Disable X.
25 echo -n "Disabling X login manager: slim..."
26 . /etc/rcS.conf
27 RUN_DAEMONS=$(echo $RUN_DAEMONS | sed s/' slim'/''/)
28 sed -i s/"RUN_DAEMONS.*"/"RUN_DAEMONS=\"$RUN_DAEMONS\"/" /etc/rcS.conf
29 status ;;
30 screen=*)
31 SCREEN=${opt#screen=} ;;
32 *)
33 continue ;;
34 esac
35 done
37 # Sound configuration stuff. First check if sound=no and remove all
38 # sound Kernel modules.
39 if [ -n "$DRIVER" ]; then
40 case "$DRIVER" in
41 no)
42 echo -n "Removing all sound kernel modules..."
43 rm -rf /lib/modules/`uname -r`/kernel/sound
44 status
45 echo -n "Removing all sound packages..."
46 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
47 pkg=${i#/var/lib/tazpkg/installed/}
48 echo 'y' | tazpkg remove ${pkg%/*} > /dev/null
49 done
50 for i in alsa-lib mhwaveedit asunder libcddb ; do
51 echo 'y' | tazpkg remove $i > /dev/null
52 done
53 status ;;
54 noconf)
55 echo "Sound configuration was disabled from cmdline..." ;;
56 *)
57 if [ -x /usr/sbin/soundconf ]; then
58 echo "Using sound kernel module $DRIVER..."
59 /usr/sbin/soundconf -M $DRIVER
60 fi ;;
61 esac
62 # Sound card may already be detected by PCI-detect.
63 elif [ -d /proc/asound ]; then
64 # Restore sound config for installed system.
65 if [ -s /var/lib/alsa/asound.state ]; then
66 echo -n "Restoring last alsa configuration..."
67 alsactl restore
68 status
69 else
70 /usr/sbin/setmixer
71 fi
72 # Start soundconf to config driver and load module for Live mode
73 # if not yet detected.
74 /usr/bin/amixer >/dev/null || /usr/sbin/soundconf
75 else
76 echo "Unable to configure sound card."
77 fi
79 # Start TazPanel
80 [ -x /usr/bin/tazpanel ] && tazpanel start
82 # Auto recharge packages list (after network connection of course)
83 [ "$RECHARGE_PACKAGES_LIST" == "yes" ] && tazpkg recharge &
85 # Locale config.
86 echo "Checking if /etc/locale.conf exists... "
87 if [ ! -s "/etc/locale.conf" ]; then
88 echo "Setting system locale to: POSIX (English)"
89 echo -e "LANG=POSIX\nLC_ALL=POSIX" > /etc/locale.conf
90 fi
91 . /etc/locale.conf
92 echo -n "Locale configuration: $LANG"
93 export LC_ALL
94 . /lib/libtaz.sh && status
96 # Keymap config. Default to us in live mode if kmap= was not used.
97 if [ ! -s "/etc/keymap.conf" ]; then
98 echo "us" > /etc/keymap.conf
99 fi
100 kmap=$(cat /etc/keymap.conf)
101 echo "Keymap configuration: $kmap"
102 /sbin/tazkeymap $kmap
104 # Timezone config. Set timezone using the keymap config for fr, be, fr_CH
105 # and ca with Montreal.
106 if [ ! -s "/etc/TZ" ]; then
107 case "$kmap" in
108 fr-latin1|be-latin1)
109 echo "Europe/Paris" > /etc/TZ ;;
110 fr_CH-latin1|de_CH-latin1)
111 echo "Europe/Zurich" > /etc/TZ ;;
112 cf)
113 echo "America/Montreal" > /etc/TZ ;;
114 *)
115 echo "UTC" > /etc/TZ ;;
116 esac
117 fi
119 # Xorg auto configuration.
120 if [ "$SCREEN" != "text" -a ! -s /etc/X11/xorg.conf -a -x /usr/bin/Xorg ]; then
121 echo "Configuring Xorg..."
122 # $HOME is not yet set.
123 HOME=/root
124 sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf
125 sed -i s/"^xserver_arguments"/'\#xserver_arguments'/ /etc/slim.conf
126 tazx config-xorg 2>/var/log/xorg.configure.log
127 fi
129 # Start X sesssion as soon as possible in Live/frugal mode. HD install
130 # can use FAST_BOOT_X which starts X beforehand. In live mode we need
131 # keymap config for Xorg configuration and a working Xorg config.
132 #if [ "$SCREEN" != "text" ] && [ -x /usr/bin/slim ]; then
133 #if fgrep -q root=/dev/null /proc/cmdline; then
134 #/etc/init.d/slim start
135 #fi
136 #fi
138 # Firefox hack to get the right locale.
139 if fgrep -q "fr_" /etc/locale.conf; then
140 # But is the fox installed ?
141 if [ -f "/var/lib/tazpkg/installed/firefox/receipt" ]; then
142 . /var/lib/tazpkg/installed/firefox/receipt
143 sed -i 's/en-US/fr/' /etc/firefox/pref/firefox-l10n.js
144 fi
145 fi