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

system.sh: remove libtaz.sh double sourcing (thanks llev), add more TZ guess
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Nov 28 13:38:43 2015 +0200 (2015-11-28)
parents 29ec74a6d359
children 200cbf34148a
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); do
15 case $opt in
16 console=*)
17 sed -i "s/tty1/${opt#console=}/g;/^tty[2-9]::/d" /etc/inittab ;;
18 sound=*)
19 DRIVER=${opt#sound=} ;;
20 xarg=*)
21 XARG="$XARG ${opt#xarg=}" ;;
22 *)
23 continue ;;
24 esac
25 done
27 # Locale config
28 if [ ! -s '/etc/locale.conf' ]; then
29 echo 'Setting system locale to: POSIX (English)'
30 echo -e 'LANG=POSIX\nLC_ALL=POSIX' > /etc/locale.conf
31 fi
32 . /etc/locale.conf
33 action 'Setting system locale: $LANG'
34 export LC_ALL=$LANG
35 status
37 # Keymap config: Default to us in live mode if kmap= was not used.
38 if [ ! -s '/etc/keymap.conf' ]; then
39 echo 'Setting system keymap to: us (USA)'
40 echo 'us' > /etc/keymap.conf
41 fi
42 kmap=$(cat /etc/keymap.conf)
43 action 'Loading console keymap: $kmap'
44 /sbin/tazkeymap $kmap >/dev/null
45 status
47 # Timezone config: Set timezone using the keymap config
48 # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
49 if [ ! -s '/etc/TZ' ]; then
50 case "$kmap" in
51 dk-*) tz='Europe/Copenhagen';;
52 de-*) tz='Europe/Berlin';;
53 es) tz='Europe/Madrid';;
54 fr-*) tz='Europe/Paris';;
55 be-*) tz='Europe/Brussels';;
56 *_CH-*) tz='Europe/Zurich';;
57 cf) tz='America/Toronto';;
58 *) tz='UTC';;
59 esac
60 echo "$tz" > /etc/TZ
61 fi
63 # Activate an eventual swap file or partition
64 if [ "$(blkid | grep 'TYPE="swap"')" ]; then
65 for swd in $(blkid | sed '/TYPE="swap"/!d;s/:.*//'); do
66 if ! grep -q "$swd " /etc/fstab; then
67 echo "Swap memory detected on: $swd"
68 cat >> /etc/fstab <<EOT
69 $swd swap swap defaults 0 0
70 EOT
71 fi
72 done
73 fi
74 if grep -q swap /etc/fstab; then
75 action 'Activating swap memory...'
76 swapon -a
77 status
78 fi
80 # Start TazPanel
81 [ -x /usr/bin/tazpanel ] && tazpanel start
83 # Kernel polling for automount
84 echo 5000 > /sys/module/block/parameters/events_dfl_poll_msecs 2>/dev/null
86 # Sound configuration stuff. First check if sound=no and remove all
87 # sound Kernel modules.
88 if [ -n "$DRIVER" ]; then
89 case "$DRIVER" in
90 no)
91 action 'Removing all sound kernel modules...'
92 rm -rf /lib/modules/$(uname -r)/kernel/sound
93 status
94 action 'Removing all sound packages...'
95 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
96 pkg=${i#/var/lib/tazpkg/installed/}
97 yes y | tazpkg remove ${pkg%/*} >/dev/null
98 done
99 for i in alsa-lib mhwaveedit asunder libcddb ; do
100 yes y | tazpkg remove $i >/dev/null
101 done
102 status ;;
103 noconf)
104 echo 'Sound configuration was disabled from cmdline...' ;;
105 *)
106 if [ -x /usr/sbin/soundconf ]; then
107 echo "Using sound kernel module $DRIVER..."
108 /usr/sbin/soundconf -M $DRIVER
109 fi ;;
110 esac
111 # Sound card may already be detected by kernel/udev
112 elif [ -d /proc/asound ]; then
113 if [ -s /var/lib/alsa/asound.state ]; then
114 # Restore sound config for installed system
115 echo 'Restoring last alsa configuration...'
116 (sleep 2; alsactl restore) &
117 else
118 # Initialize sound card
119 alsactl init
120 fi
121 else
122 echo 'WARNING: Unable to configure sound card'
123 fi