2009-08-26 17:00:38 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# timeconfig Slackware Linux timezone configuration utility.
|
|
|
|
#
|
|
|
|
# Author: Patrick Volkerding <volkerdi@slackware.com>
|
|
|
|
# Modified by: David Cantrell <david@slackware.com>, 06-Oct-2000
|
|
|
|
#
|
|
|
|
# ChangeLog:
|
2020-04-26 05:34:28 +02:00
|
|
|
# 2019-09-11: Updated timezones from tzdata2019c. <pjv>
|
2016-06-30 22:26:57 +02:00
|
|
|
# 2014-10-22: Updated timezones from tzdata2014i. <pjv>
|
2013-11-04 18:08:47 +01:00
|
|
|
# 2012-12-12: Updated timezones from tzdata2012j. <pjv>
|
2009-08-26 17:00:38 +02:00
|
|
|
# 2008-03-10: Updated timezones from tzdata2008a. <pjv>
|
|
|
|
# 2007-12-21: Updated timezones from tzdata2007j. <pjv>
|
|
|
|
# 2006-12-03: Updated timezones from tzdata2006p. <pjv>
|
|
|
|
# 2006-09-14: Updated timezones from tzdata2006k. <pjv>
|
|
|
|
# 2006-08-22: Updated timezones from tzdata2006j.
|
|
|
|
# 2006-08-13: Updated timezones from tzdata2006g.
|
|
|
|
# 2006-03-13: Updated timezones from tzdata2006c.
|
|
|
|
# 19-Feb-2001 Add new timezones from glibc-2.2.2.
|
2018-05-28 21:12:29 +02:00
|
|
|
# 06-Oct-2000 Fixed a problem with selecting UTC time. It was writing
|
2009-08-26 17:00:38 +02:00
|
|
|
# the hardwareclock file to the root disk and not your dest
|
|
|
|
# partition. Changed the HWCLOCK_CONF variable to be
|
2018-05-28 21:12:29 +02:00
|
|
|
# $T_PX/etc/hardwareclock to fix this. Thanks to David L.
|
2009-08-26 17:00:38 +02:00
|
|
|
# Dickman <softbear@optonline.net> for finding this and
|
|
|
|
# submitting a patch.
|
|
|
|
#
|
|
|
|
# 15-Mar-2000 Added the writeconf function to write out the
|
|
|
|
# /etc/hardwareclock file which tells what the hardware clock
|
|
|
|
# is set to (UTC or localtime).
|
|
|
|
#
|
2018-05-28 21:12:29 +02:00
|
|
|
# 03-Mar-2000 Reorganized script. Made one timezone set block, added
|
2009-08-26 17:00:38 +02:00
|
|
|
# stage that asks the user if the hardware clock is set to
|
|
|
|
# UTC.
|
|
|
|
|
|
|
|
# setup our temp locations and variables
|
|
|
|
TMP=/var/log/setup/tmp
|
|
|
|
if [ -r $TMP/SeTT_PX ]; then
|
|
|
|
T_PX="`cat $TMP/SeTT_PX`"
|
|
|
|
elif [ ! "$!" = "" ]; then
|
|
|
|
T_PX=$1
|
|
|
|
else
|
|
|
|
T_PX=/
|
|
|
|
fi
|
|
|
|
|
|
|
|
# the hardware clock configuration file
|
|
|
|
HWCLOCK_CONF=$T_PX/etc/hardwareclock
|
|
|
|
|
|
|
|
# setzone( $TIMEZONE )
|
|
|
|
#
|
|
|
|
# This function accepts a time zone as the only parameter and sets it as
|
|
|
|
# the default system time zone.
|
|
|
|
setzone()
|
|
|
|
{
|
|
|
|
TZ=$1
|
|
|
|
|
|
|
|
cd $T_PX/etc
|
|
|
|
if [ -r $T_PX/usr/share/zoneinfo/$TZ -o \
|
|
|
|
-r /var/log/mount/usr/share/zoneinfo/$TZ -o \
|
|
|
|
-L $T_PX/usr/share/zoneinfo/$TZ -o \
|
|
|
|
-L /var/log/mount/usr/share/zoneinfo/$TZ ]; then
|
2016-06-30 22:26:57 +02:00
|
|
|
rm -f localtime-copied-from
|
2009-08-26 17:00:38 +02:00
|
|
|
rm -f localtime
|
2020-12-09 22:10:40 +01:00
|
|
|
ln -sf /usr/share/zoneinfo/$TZ localtime
|
2009-08-26 17:00:38 +02:00
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# writeconf( $CLOCK_SET_TO )
|
|
|
|
#
|
|
|
|
# Writes out $HWCLOCK_CONF that tells rc.S how the hardware clock
|
|
|
|
# value is stored.
|
|
|
|
writeconf()
|
|
|
|
{
|
|
|
|
echo "# /etc/hardwareclock" > $HWCLOCK_CONF
|
|
|
|
echo "#" >> $HWCLOCK_CONF
|
|
|
|
echo "# Tells how the hardware clock time is stored." >> $HWCLOCK_CONF
|
|
|
|
echo "# You should run timeconfig to edit this file." >> $HWCLOCK_CONF
|
|
|
|
echo >> $HWCLOCK_CONF
|
|
|
|
echo $1 >> $HWCLOCK_CONF
|
|
|
|
}
|
|
|
|
|
|
|
|
# ask the user if the hardware clock is set for UTC/GMT
|
|
|
|
if [ "$COLOR" = "on" -o -r $TMP/SeTcolor -o "$T_PX" = "/" ]; then
|
|
|
|
###
|
|
|
|
### use color menus here
|
|
|
|
###
|
|
|
|
dialog --title "HARDWARE CLOCK SET TO UTC?" --menu "Is the hardware clock set \
|
2018-05-28 21:12:29 +02:00
|
|
|
to Coordinated Universal Time (UTC/GMT)? If it is, select YES here. If the \
|
2009-08-26 17:00:38 +02:00
|
|
|
hardware clock is set to the current local time (this is how most PCs are set \
|
2018-05-28 21:12:29 +02:00
|
|
|
up), then say NO here. If you are not sure what this is, you should answer NO \
|
2009-08-26 17:00:38 +02:00
|
|
|
here." 13 60 2 \
|
|
|
|
"NO" "Hardware clock is set to local time" \
|
|
|
|
"YES" "Hardware clock is set to UTC" \
|
|
|
|
2> $TMP/utc
|
|
|
|
if [ $? = 1 -o $? = 255 ]; then
|
|
|
|
rm -f $TMP/utc
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ "`cat $TMP/utc`" = "YES" ]; then
|
|
|
|
# yes, the hardware clock is UTC
|
|
|
|
writeconf "UTC"
|
|
|
|
else # must be NO
|
|
|
|
writeconf "localtime"
|
|
|
|
fi
|
|
|
|
rm -f $TMP/utc
|
|
|
|
else
|
|
|
|
###
|
|
|
|
### use text prompts
|
|
|
|
###
|
|
|
|
echo "Is the hardware clock set to Coordinated Universal Time (UTC/GMT)?"
|
2018-05-28 21:12:29 +02:00
|
|
|
echo "If it is, select 'y' here. If the hardware clock is set to the"
|
2009-08-26 17:00:38 +02:00
|
|
|
echo "current local time (this is how most PCs are set up), then say 'n'"
|
2018-05-28 21:12:29 +02:00
|
|
|
echo "here. If you are not sure what this is, you should answer 'n' here."
|
2009-08-26 17:00:38 +02:00
|
|
|
echo
|
|
|
|
echo -n "Is your hardware clock set to UTC ([y]es, [n]o)? "
|
|
|
|
read HEJAZ
|
|
|
|
|
|
|
|
if [ "$HEJAZ" = "y" -o "$HEJAZ" = "Y" -o "$HEJAZ" = "YES" -o "$HEJAZ" = "yes" ]; then
|
|
|
|
# yes, the hardware clock is UTC
|
|
|
|
writeconf "UTC"
|
|
|
|
else
|
|
|
|
# default to localtime
|
|
|
|
writeconf "localtime"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Now set the correct timezone link:
|
|
|
|
if [ "$COLOR" = "on" -o -r $TMP/SeTcolor -o "$T_PX" = "/" ]; then
|
|
|
|
###
|
|
|
|
### use color menus here
|
|
|
|
###
|
|
|
|
dialog --title "TIMEZONE CONFIGURATION" --menu "Please select one of the following timezones for your machine:" 21 50 13 \
|