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

Fis sound card config initialization on first boot
author Christophe Lincoln <pankso@slitaz.org>
date Mon May 05 22:08:51 2014 +0200 (2014-05-05)
parents 27c455a9f7ac
children 95da8328cbb5
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 *)
25 continue ;;
26 esac
27 done
29 # Sound configuration stuff. First check if sound=no and remove all
30 # sound Kernel modules.
31 if [ -n "$DRIVER" ]; then
32 case "$DRIVER" in
33 no)
34 echo -n "Removing all sound kernel modules..."
35 rm -rf /lib/modules/$(uname -r)/kernel/sound
36 status
37 echo -n "Removing all sound packages..."
38 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
39 pkg=${i#/var/lib/tazpkg/installed/}
40 echo 'y' | tazpkg remove ${pkg%/*} > /dev/null
41 done
42 for i in alsa-lib mhwaveedit asunder libcddb ; do
43 echo 'y' | tazpkg remove $i > /dev/null
44 done
45 status ;;
46 noconf)
47 echo "Sound configuration was disabled from cmdline..." ;;
48 *)
49 if [ -x /usr/sbin/soundconf ]; then
50 echo "Using sound kernel module $DRIVER..."
51 /usr/sbin/soundconf -M $DRIVER
52 fi ;;
53 esac
54 # Sound card may already be detected by kernel/udev
55 elif [ -d /proc/asound ]; then
56 # Restore sound config for installed system
57 if [ -s /var/lib/alsa/asound.state ]; then
58 echo -n "Restoring last alsa configuration..."
59 alsactl restore
60 status
61 else
62 # Initialize sound card
63 alsactl init
64 fi
65 else
66 echo "Unable to configure sound card."
67 fi
69 # Locale config
70 if [ ! -s "/etc/locale.conf" ]; then
71 echo "Setting system locale to: POSIX (English)"
72 echo -e "LANG=POSIX\nLC_ALL=POSIX" > /etc/locale.conf
73 fi
74 . /etc/locale.conf
75 echo -n "Setting system locale: $LANG"
76 export LC_ALL=$LANG
77 . /lib/libtaz.sh && status
79 # Keymap config: Default to us in live mode if kmap= was not used.
80 if [ ! -s "/etc/keymap.conf" ]; then
81 echo "Setting system keymap to: us (USA)"
82 echo "us" > /etc/keymap.conf
83 fi
84 kmap=$(cat /etc/keymap.conf)
85 echo -n "Loading console keymap: $kmap"
86 /sbin/tazkeymap $kmap >/dev/null
87 status
89 # Timezone config: Set timezone using the keymap config for fr, be, fr_CH
90 # and ca with Montreal.
91 if [ ! -s "/etc/TZ" ]; then
92 case "$kmap" in
93 fr-latin1|be-latin1)
94 echo "Europe/Paris" > /etc/TZ ;;
95 fr_CH-latin1|de_CH-latin1)
96 echo "Europe/Zurich" > /etc/TZ ;;
97 cf) echo "America/Montreal" > /etc/TZ ;;
98 *) echo "UTC" > /etc/TZ ;;
99 esac
100 fi
102 # Activate an eventual swap file or partition
103 if [ "$(blkid | grep 'TYPE="swap"')" ]; then
104 for swd in $(blkid | sed '/TYPE="swap"/!d;s/:.*//'); do
105 if ! grep -q "$swd " /etc/fstab; then
106 echo "Swap memory detected on: $swd"
107 cat >> /etc/fstab <<EOT
108 $swd swap swap defaults 0 0
109 EOT
110 fi
111 done
112 fi
113 if grep -q swap /etc/fstab; then
114 echo -n "Activating swap memory..."
115 swapon -a && status
116 fi
118 # Start TazPanel
119 [ -x /usr/bin/tazpanel ] && tazpanel start
121 # Kernel polling for automount
122 echo 5000 > /sys/module/block/parameters/events_dfl_poll_msecs 2>/dev/null