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

gettext needs locale definition files
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Feb 21 14:07:33 2021 +0000 (2021-02-21)
parents 7763f4f1665c
children d37d21683dd1
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 # 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: %s' "$LANG"
34 [ -d /usr/lib/locale/${LANG%.*} ] ||
35 localdef -i ${LANG%.*} -c -f UTF-8 /usr/lib/locale/${LANG%.*}
36 export LC_ALL=$LANG
37 status
39 # Keymap config: Default to us in live mode if kmap= was not used.
40 if [ ! -s '/etc/keymap.conf' ]; then
41 # Setting system keymap to: us (USA)
42 echo 'us' > /etc/keymap.conf
43 fi
44 kmap=$(cat /etc/keymap.conf)
45 action 'Loading console keymap: %s' "$kmap"
46 /sbin/tazkeymap $kmap >/dev/null
47 status
49 # Timezone config: Set timezone using the keymap config
50 # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
51 if [ ! -s '/etc/TZ' ]; then
52 case "$kmap" in
53 dk-*) tz='Europe/Copenhagen';;
54 de-*) tz='Europe/Berlin';;
55 es) tz='Europe/Madrid';;
56 fr-*) tz='Europe/Paris';;
57 be-*) tz='Europe/Brussels';;
58 *_CH-*) tz='Europe/Zurich';;
59 cf) tz='America/Toronto';;
60 *) tz='UTC';;
61 esac
62 echo "$tz" > /etc/TZ
63 fi
65 # Activate an eventual swap file or partition
66 if ! grep -q 'noswap' /proc/cmdline; then
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 if grep -q swap /etc/fstab; then
78 action 'Activating swap memory...'
79 swapon -a
80 status
81 fi
82 fi
84 # Start TazPanel
85 [ -x /usr/bin/tazpanel ] && tazpanel start
87 # Kernel polling for automount
88 echo 5000 > /sys/module/block/parameters/events_dfl_poll_msecs 2>/dev/null
90 # Sound configuration stuff. First check if sound=no and remove all
91 # sound Kernel modules.
92 if [ -n "$DRIVER" ]; then
93 case "$DRIVER" in
94 no)
95 action 'Removing all sound kernel modules...'
96 rm -rf /lib/modules/$(uname -r)/kernel/sound
97 status
98 action 'Removing all sound packages...'
99 for i in $(grep -l '^DEPENDS=.*alsa-lib' /var/lib/tazpkg/installed/*/receipt) ; do
100 pkg=${i#/var/lib/tazpkg/installed/}
101 yes y | tazpkg remove ${pkg%/*} >/dev/null
102 done
103 for i in alsa-lib mhwaveedit asunder libcddb ; do
104 yes y | tazpkg remove $i >/dev/null
105 done
106 status ;;
107 noconf)
108 echo 'Sound configuration was disabled from cmdline...' ;;
109 *)
110 if [ -x /usr/sbin/soundconf ]; then
111 echo "Using sound kernel module $DRIVER..."
112 /usr/sbin/soundconf -M $DRIVER
113 fi ;;
114 esac
115 # Sound card may already be detected by kernel/udev
116 elif [ -d /proc/asound ]; then
117 if [ -s /var/lib/alsa/asound.state ]; then
118 # Restore sound config for installed system
119 echo 'Restoring last alsa configuration...'
120 (sleep 2; alsactl restore) &
121 else
122 # Initialize sound card
123 alsactl init
124 fi
125 else
126 echo 'WARNING: Unable to configure sound card'
127 fi