localtime/UTC corrections to the TZ script

The previous code handled timezone changes poorly when
fiddling with the hwclock. Add localtime/UTC selection
for the hwclock to circumvent this

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
This commit is contained in:
Gerhard Brauer 2008-12-18 09:40:51 -08:00 committed by Aaron Griffin
parent 1b248c4ed6
commit 2267d62099

View File

@ -1,10 +1,12 @@
#!/bin/bash #!/bin/bash
# written by Tobias Powalowski <tpowa@archlinux.org> # written by Tobias Powalowski <tpowa@archlinux.org>
# modified by Gerhard Brauer <gerbra@archlinux.de>
ANSWER="/tmp/.tz" ANSWER="/tmp/.tz"
PATH=$PATH:/tmp/bin:/tmp/usr/bin:/tmp/sbin:/tmp/usr/sbin PATH=$PATH:/tmp/bin:/tmp/usr/bin:/tmp/sbin:/tmp/usr/sbin
TITLE="Arch Linux Time Setting" TITLE="Arch Linux Time Setting"
BASEDIR="/usr/share/zoneinfo" BASEDIR="/usr/share/zoneinfo"
CLOCKSOURCE="localtime"
abort() abort()
{ {
@ -74,6 +76,9 @@ dotimezone () {
REGIONS="" REGIONS=""
SET_REGION="" SET_REGION=""
SET_ZONE="" SET_ZONE=""
dodialog yesno "Your current BIOS time is:\n$(hwclock)\n\nIf your BIOS clock is set to UTC choose YES\nOtherwise (or if unsure) choose NO" 15 65 && CLOCKSOURCE="UTC"
for i in $(grep ^[A-Z] $BASEDIR/zone.tab | cut -f 3 | sed -e 's#/.*##g'| sort -u); do for i in $(grep ^[A-Z] $BASEDIR/zone.tab | cut -f 3 | sed -e 's#/.*##g'| sort -u); do
REGIONS="$REGIONS $i -" REGIONS="$REGIONS $i -"
done done
@ -90,6 +95,16 @@ if [ "${SET_REGION}" = "1" ]; then
echo $region/$zone > /tmp/.timezone echo $region/$zone > /tmp/.timezone
[ -e /etc/localtime ] && rm -f /etc/localtime [ -e /etc/localtime ] && rm -f /etc/localtime
cp $BASEDIR/$region/$zone /etc/localtime cp $BASEDIR/$region/$zone /etc/localtime
# after timezone changing set the system time back to hwclock value.
# Mostly on new installations the bios clock represent the correct time
# for the user. Either it is the users localtime or he has set the BIOS
# to UTC. CLOCKSOURCE value choose how the system time is resetted.
if [ "${CLOCKSOURCE}" = "UTC" ]; then
hwclock --hctosys --utc
else
hwclock --hctosys
fi
dohwclock dohwclock
else else
dodialog msgbox "Skipping Region and Timezone, else please select a Timezone!" dodialog msgbox "Skipping Region and Timezone, else please select a Timezone!"
@ -113,7 +128,7 @@ USE_NTPDATE=""
dodialog yesno "Do you want to use UTC for your clock?\n\nIf you choose 'YES' UTC (recommended default) is used,\nwhich ensures daylightsaving is set automatically.\n\nIf you choose 'NO' Localtime is used,\nwhich means the system will not change the time.\nLocaltime is also prefered on dualboot machines,\nwhich also run Windows, because UTC confuses it." 15 65 && HARDWARECLOCK="UTC" dodialog yesno "Do you want to use UTC for your clock?\n\nIf you choose 'YES' UTC (recommended default) is used,\nwhich ensures daylightsaving is set automatically.\n\nIf you choose 'NO' Localtime is used,\nwhich means the system will not change the time.\nLocaltime is also prefered on dualboot machines,\nwhich also run Windows, because UTC confuses it." 15 65 && HARDWARECLOCK="UTC"
dodialog infobox "Syncing hardwareclock to systemclock ..." dodialog infobox "Syncing hardwareclock to systemclock ..."
HWCLOCK_PARAMS="--hctosys" HWCLOCK_PARAMS="--hctosys"
dodialog yesno "Your current time is:\n$(date)\n\nDo you want to change it?" "" "" && SET_TIME="1" dodialog yesno "Your (new) current time is:\n$(date)\n\nDo you want to correct it?" "" "" && SET_TIME="1"
if [ "${SET_TIME}" = "1" ]; then if [ "${SET_TIME}" = "1" ]; then
[ $(which ntpdate) ] && dodialog yesno "'ntpdate' was detected on your system.\n\nDo you want to use 'ntpdate' for syncing your clock,\nby using the internet clock pool?\n(You need a working internet connection for doing this!)" "" "" default=no && USE_NTPDATE="1" [ $(which ntpdate) ] && dodialog yesno "'ntpdate' was detected on your system.\n\nDo you want to use 'ntpdate' for syncing your clock,\nby using the internet clock pool?\n(You need a working internet connection for doing this!)" "" "" default=no && USE_NTPDATE="1"
if [ "${USE_NTPDATE}" = "1" ]; then if [ "${USE_NTPDATE}" = "1" ]; then
@ -141,8 +156,6 @@ if [ "${SET_TIME}" = "1" ]; then
dohwclock dohwclock
dodialog msgbox "Your current time is now:\n$(date)" dodialog msgbox "Your current time is now:\n$(date)"
fi fi
else
dodialog msgbox "Current time was not changed!"
fi fi
S_NEXTITEM="3" S_NEXTITEM="3"
} }