Adding casper 1.63+debian-1.
[live-boot-grml.git] / scripts / casper-bottom / 14locales
1 #! /bin/sh
2
3 PREREQ=""
4 DESCRIPTION="Setting up locales..."
5
6 . /scripts/functions
7
8 prereqs()
9 {
10        echo "$PREREQ"
11 }
12
13 case $1 in
14 # get pre-requisites
15 prereqs)
16        prereqs
17        exit 0
18        ;;
19 esac
20
21 log_begin_msg "$DESCRIPTION"
22
23 if [ -e /root/etc/default/locale ]; then
24         grep_file=/root/etc/default/locale
25         locale=$(grep 'LANG=' ${grep_file} | sed s/'LANG='// | tr -d '"' ) 
26 elif [ -e /root/etc/environment ]; then # Old locales policy
27         grep_file=/root/etc/environment
28 fi
29
30 # commandline
31 for x in $(cat /proc/cmdline); do
32         case $x in
33                 debian-installer/locale=*)
34                         locale=${x#debian-installer/locale=}
35                         set_locale="true"
36                         ;;
37         esac
38 done
39
40 if [ -z "${locale}" ]; then
41         # Set a default one
42         locale=en_US.UTF-8
43         set_locale="true"
44 fi
45
46 if [ "${set_locale}" ]; then
47         LANG=$(grep "^${locale}" /root/usr/share/i18n/SUPPORTED | grep UTF-8 |sed -e 's, .*,,' -e q)
48         printf 'LANG="%s"\n' "${LANG}" >> "${grep_file}" 
49         chroot /root /usr/sbin/locale-gen "${LANG}"
50 fi
51
52 log_end_msg