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

Small fix for system.sh and be less verbose on logout
author Christophe Lincoln <pankso@slitaz.org>
date Tue May 17 15:10:21 2011 +0200 (2011-05-17)
parents 7cae07b36655
children bfb8a5936ba1
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 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 "Starting TazBox configuration..."
87 DISPLAY=:1 tazbox boot
88 else
89 tazlocale
90 fi
91 else
92 lang=$(cat /etc/locale.conf | fgrep LANG | cut -d "=" -f 2)
93 echo -n "Locale configuration: $lang" && status
94 fi
96 # Keymap config.
97 if [ -s "/etc/keymap.conf" ]; then
98 KEYMAP=$(cat /etc/keymap.conf)
99 echo "Keymap configuration: $KEYMAP"
100 if [ -x /bin/loadkeys ]; then
101 loadkeys $KEYMAP
102 else
103 loadkmap < /usr/share/kmap/$KEYMAP.kmap
104 fi
105 else
106 tazkeymap
107 fi
109 # Timezone config. Set timezone using the keymap config for fr, be, fr_CH
110 # and ca with Montreal.
111 if [ ! -s "/etc/TZ" ]; then
112 map=$(cat /etc/keymap.conf)
113 case "$map" in
114 fr-latin1|be-latin1)
115 echo "Europe/Paris" > /etc/TZ ;;
116 fr_CH-latin1|de_CH-latin1)
117 echo "Europe/Zurich" > /etc/TZ ;;
118 cf)
119 echo "America/Montreal" > /etc/TZ ;;
120 *)
121 echo "UTC" > /etc/TZ ;;
122 esac
123 fi
125 # Xorg auto configuration.
126 if [ "$SCREEN" != "text" -a ! -s /etc/X11/xorg.conf -a -x /usr/bin/Xorg ]; then
127 echo "Configuring Xorg..."
128 # $HOME is not yet set.
129 HOME=/root
130 sed -i 's|/usr/bin/Xvesa|/usr/bin/Xorg|' /etc/slim.conf
131 sed -i s/"^xserver_arguments"/'\#xserver_arguments'/ /etc/slim.conf
132 tazx config-xorg 2>/var/log/xorg.configure.log
133 fi
135 # Start X sesssion as soon as possible in Live/frugal mode. HD install
136 # can use FAST_BOOT_X which starts X beforehand. In live mode we need
137 # keymap config for Xorg configuration and a working Xorg config.
138 #if [ "$SCREEN" != "text" ] && [ -x /usr/bin/slim ]; then
139 #if fgrep -q root=/dev/null /proc/cmdline; then
140 #/etc/init.d/slim start
141 #fi
142 #fi
144 # Firefox hack to get the right locale.
145 if fgrep -q "fr_" /etc/locale.conf; then
146 # But is the fox installed ?
147 if [ -f "/var/lib/tazpkg/installed/firefox/receipt" ]; then
148 . /var/lib/tazpkg/installed/firefox/receipt
149 sed -i 's/en-US/fr/' /etc/firefox/pref/firefox-l10n.js
150 fi
151 fi