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

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