de37666c4652cd9f810cbb80f5047abac03cd16c
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 18-timesetup
1 #!/bin/bash
2 # Filename:      /etc/grml/fai/config/scripts/GRMLBASE/18-timesetup
3 # Purpose:       apply default time and timezone settings
4 # Authors:       (c) Thomas Lehmann <thomas.lehmann@kvt.de>
5 # Bug-Reports:   send to author and see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2 or any later version.
7 ###############################################################################
8
9 set -u
10 set -e
11
12 # tell if hwclock is running in UTC or local time
13 # by default it's set to UTC=yes, we usually want UTC=no
14 if [ -n "$UTC" ] ; then
15    echo "Setting hwclock parameter UTC to $UTC"
16    sed -i "s|^UTC=.*$|UTC="$UTC"|" $target/etc/default/rcS
17 fi
18
19 # default timezone settings
20 if [ -n "$TIMEZONE" ] ; then
21    echo "Setting default timezone to $TIMEZONE"
22    # update debconf
23    area=$(echo $TIMEZONE | cut -d '/' -f1)
24    zone=$(echo $TIMEZONE | cut -d '/' -f2)
25    echo "tzdata tzdata/Areas       select $area" | $ROOTCMD debconf-set-selections
26    echo "tzdata tzdata/Zones/$area select $zone" | $ROOTCMD debconf-set-selections
27    # update files
28    echo $TIMEZONE > $target/etc/timezone
29    rm -f $target/etc/localtime
30    cp -f $target/usr/share/zoneinfo/$TIMEZONE $target/etc/localtime
31 fi
32
33 ## END OF FILE ################################################################
34 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3