Merge remote-tracking branch 'origin/github/pr/145'
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 18-timesetup
1 #!/bin/bash
2 # Filename:      ${GRML_FAI_CONFIG}/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=no
14 if [ -n "$UTC" ] && [ "$UTC" = "yes" ] ; then
15    echo "UTC is set to 'yes', setting hwclock parameter UTC"
16    [ -e "${target}/etc/adjtime" ] && sed -i "s/^LOCAL/UTC/" "${target}/etc/adjtime"
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=2