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

system.sh: dont search for swap on each boot
author Christophe Lincoln <pankso@slitaz.org>
date Fri Jul 11 15:42:01 2014 +0200 (2014-07-11)
parents 95da8328cbb5
children 19cbb42ff322
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 grep -q swap /etc/fstab; then
64 echo -n "Activating swap memory..."
65 swapon -a && status
66 else
67 if [ "$(blkid | grep 'TYPE="swap"')" ]; then
68 for swd in $(blkid | sed '/TYPE="swap"/!d;s/:.*//'); do
69 if ! grep -q "$swd " /etc/fstab; then
70 echo "Swap memory detected on: $swd"
71 cat >> /etc/fstab <<EOT
72 $swd swap swap defaults 0 0
73 EOT
74 fi
75 done
76 fi
77 fi
79 # Start TazPanel
80 [ -x /usr/bin/tazpanel ] && tazpanel start
82 # Kernel polling for automount
83 echo 5000 > /sys/module/block/parameters/events_dfl_poll_msecs 2>/dev/null
85 # Sound configuration stuff. First check if sound=no and remove all
86 # sound Kernel modules.
87 if [ -n "$DRIVER" ]; then
88 case "$DRIVER" in
89 no)
90 echo -n "Removing all sound kernel modules..."
91 rm -rf /lib/modules/$(uname -r)/kernel/sound
92 status
93 echo -n "Removing all sound packages..."
94 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
95 pkg=${i#/var/lib/tazpkg/installed/}
96 echo 'y' | tazpkg remove ${pkg%/*} > /dev/null
97 done
98 for i in alsa-lib mhwaveedit asunder libcddb ; do
99 echo 'y' | tazpkg remove $i > /dev/null
100 done
101 status ;;
102 noconf)
103 echo "Sound configuration was disabled from cmdline..." ;;
104 *)
105 if [ -x /usr/sbin/soundconf ]; then
106 echo "Using sound kernel module $DRIVER..."
107 /usr/sbin/soundconf -M $DRIVER
108 fi ;;
109 esac
110 # Sound card may already be detected by kernel/udev
111 elif [ -d /proc/asound ]; then
112 if [ -s /var/lib/alsa/asound.state ]; then
113 # Restore sound config for installed system
114 echo "Restoring last alsa configuration..."
115 (sleep 2; alsactl restore) &
116 else
117 # Initialize sound card
118 alsactl init
119 fi
120 else
121 echo "WARNING: Unable to configure sound card"
122 fi