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

Fix bug: http://bugs.slitaz.org/?id=71
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Sat Jan 05 00:07:04 2013 +0100 (2013-01-05)
parents b08c444c5675
children 6985bc31569e
line source
1 #!/bin/sh
2 #
3 # /etc/init.d/system.sh : SliTaz hardware configuration
4 #
5 # This script configures the sound card and screen. Tazhw is used earlier
6 # at boot time to autoconfigure PCI and USB devices. It also configures
7 # system language, keyboard and TZ in live mode and start X.
8 #
9 . /etc/init.d/rc.functions
10 . /etc/rcS.conf
12 # Parse cmdline args for boot options (See also rcS and bootopts.sh).
13 XARG=""
14 for opt in $(cat /proc/cmdline)
15 do
16 case $opt in
17 console=*)
18 sed -i "s/tty1/${opt#console=}/g;/^tty[2-9]::/d" \
19 /etc/inittab ;;
20 sound=*)
21 DRIVER=${opt#sound=} ;;
22 xarg=*)
23 XARG="$XARG ${opt#xarg=}" ;;
24 screen=*)
25 SCREEN=${opt#screen=} ;;
26 *)
27 continue ;;
28 esac
29 done
31 # Sound configuration stuff. First check if sound=no and remove all
32 # sound Kernel modules.
33 if [ -n "$DRIVER" ]; then
34 case "$DRIVER" in
35 no)
36 echo -n "Removing all sound kernel modules..."
37 rm -rf /lib/modules/$(uname -r)/kernel/sound
38 status
39 echo -n "Removing all sound packages..."
40 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
41 pkg=${i#/var/lib/tazpkg/installed/}
42 echo 'y' | tazpkg remove ${pkg%/*} > /dev/null
43 done
44 for i in alsa-lib mhwaveedit asunder libcddb ; do
45 echo 'y' | tazpkg remove $i > /dev/null
46 done
47 status ;;
48 noconf)
49 echo "Sound configuration was disabled from cmdline..." ;;
50 *)
51 if [ -x /usr/sbin/soundconf ]; then
52 echo "Using sound kernel module $DRIVER..."
53 /usr/sbin/soundconf -M $DRIVER
54 fi ;;
55 esac
56 # Sound card may already be detected by PCI-detect.
57 elif [ -d /proc/asound ]; then
58 # Restore sound config for installed system.
59 if [ -s /var/lib/alsa/asound.state ]; then
60 echo -n "Restoring last alsa configuration..."
61 alsactl restore
62 status
63 else
64 /usr/sbin/setmixer
65 fi
66 # Start soundconf to config driver and load module for Live mode
67 # if not yet detected.
68 /usr/bin/amixer >/dev/null || /usr/sbin/soundconf
69 else
70 echo "Unable to configure sound card."
71 fi
73 # Locale config
74 if [ ! -s "/etc/locale.conf" ]; then
75 echo "Setting system locale to: POSIX (English)"
76 echo -e "LANG=POSIX\nLC_ALL=POSIX" > /etc/locale.conf
77 fi
78 . /etc/locale.conf
79 echo -n "Setting system locale: $LANG"
80 export LC_ALL=$LANG
81 . /lib/libtaz.sh && status
83 # Keymap config: Default to us in live mode if kmap= was not used.
84 if [ ! -s "/etc/keymap.conf" ]; then
85 echo "Setting system keymap to: us (USA)"
86 echo "us" > /etc/keymap.conf
87 fi
88 kmap=$(cat /etc/keymap.conf)
89 echo -n "Loading console keymap: $kmap"
90 /sbin/tazkeymap $kmap >/dev/null
91 status
93 # Timezone config: Set timezone using the keymap config for fr, be, fr_CH
94 # and ca with Montreal.
95 if [ ! -s "/etc/TZ" ]; then
96 case "$kmap" in
97 fr-latin1|be-latin1)
98 echo "Europe/Paris" > /etc/TZ ;;
99 fr_CH-latin1|de_CH-latin1)
100 echo "Europe/Zurich" > /etc/TZ ;;
101 cf) echo "America/Montreal" > /etc/TZ ;;
102 *) echo "UTC" > /etc/TZ ;;
103 esac
104 fi
106 # Activate an eventual swap file or partition
107 if [ "$(blkid | grep 'TYPE="swap"')" ]; then
108 for swd in $(blkid | sed '/TYPE="swap"/!d;s/:.*//'); do
109 if ! grep -q "$swd " /etc/fstab; then
110 echo "Swap memory detected on: $swd"
111 cat >> /etc/fstab <<EOT
112 $swd swap swap defaults 0 0
113 EOT
114 fi
115 done
116 fi
117 if grep -q swap /etc/fstab; then
118 echo -n "Activating swap memory..."
119 swapon -a && status
120 fi
122 # Xorg auto configuration: $HOME is not yet set. We config even if
123 # screen=text so X can be started by users via 'startx'
124 if [ ! -s /etc/X11/xorg.conf ] && [ -x /usr/bin/Xorg ]; then
125 echo "Configuring Xorg..."
126 HOME=/root
127 tazx config-xorg 2>/var/log/xorg.configure.log
128 fi
130 # Start X sesssion as soon as possible
131 if [ "$SCREEN" != "text" ] && [ "$LOGIN_MANAGER" ]; then
132 echo -n "Starting X environment..."
133 /etc/init.d/dbus start >/dev/null
134 if [ $(/bin/hostname) == '(none)' ];then
135 /bin/hostname -F /etc/hostname
136 fi
137 /etc/init.d/$LOGIN_MANAGER start >/dev/null &
138 status
139 fi
141 # Start TazPanel
142 [ -x /usr/bin/tazpanel ] && tazpanel start