#!/bin/sh # # timeconfig Slackware Linux timezone configuration utility. # # Author: Patrick Volkerding # Modified by: David Cantrell , 06-Oct-2000 # Modified bt Didier Spaier following a suggestion by Xsane, 18-02-2016 # ChangeLog: # 2014-10-22: Updated timezones from tzdata2014i. # 2012-12-12: Updated timezones from tzdata2012j. # 2008-03-10: Updated timezones from tzdata2008a. # 2007-12-21: Updated timezones from tzdata2007j. # 2006-12-03: Updated timezones from tzdata2006p. # 2006-09-14: Updated timezones from tzdata2006k. # 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. # 06-Oct-2000 Fixed a problem with selecting UTC time. It was writing # the hardwareclock file to the root disk and not your dest # partition. Changed the HWCLOCK_CONF variable to be # $T_PX/etc/hardwareclock to fix this. Thanks to David L. # Dickman 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). # # 03-Mar-2000 Reorganized script. Made one timezone set block, added # stage that asks the user if the hardware clock is set to # UTC. # setup our temp locations and variables export TEXTDOMAIN=slint . gettext.sh 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 IFS=$'\t\n' # the hardware clock configuration file HWCLOCK_CONF=$T_PX/etc/hardwareclock # the time zone database file index ZONETAB=$T_PX/usr/share/zoneinfo/zone1970.tab # 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 rm -f localtime-copied-from ln -sf /usr/share/zoneinfo/$TZ localtime-copied-from rm -f localtime cd .. chroot . cp etc/localtime-copied-from etc/localtime 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 --visit-items --title "`gettext "HARDWARE CLOCK SET TO UTC?"`" --menu "`gettext "Is the hardware clock set \ to Coordinated Universal Time (UTC/GMT)? If it is, select YES here. If the \ hardware clock is set to the current local time (this is how most PCs are set \ up), then say NO here. If you are not sure what this is, you should answer NO \ here."`" 13 80 2 \ "NO" "`gettext "Hardware clock is set to local time"`" \ "YES" "`gettext "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 ### gettext "Is the hardware clock set to Coordinated Universal Time (UTC/GMT) If it is, select 'y' here. If the hardware clock is set to the current local time (this is how most PCs are set up), then say 'n' here. If you are not sure what this is, you should answer 'n' here. Is your hardware clock set to UTC " echo -n "([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 ### # Replace all U+0020 but the first by U+00A0 to keep all the comment # on one line, but tentatively replace the first by a control # character to avoid convert it (it separes the tag from the item). # No: just set IFS properly, suggested by Xsane on linuxquestions.org dialog --no-tags --visit-items --title "`gettext "TIMEZONE CONFIGURATION"`" \ --menu "`gettext "Please select one of the following timezones for your machine:"`" 0 0 0 \ $(cut -f3- $ZONETAB|grep '/'|sort|sed "s/\t/ => /"|awk '{print $1 "\t" $0}'; echo -e "UTC\tUTC") \ 2> $TMP/tz # $(cut -f3- $ZONETAB|grep '/'|sort|sed "s/\t/ /"|awk '{print $1 " " $0}'|sed "s/ //;s/ / => /;s/ / /g;s// /"; echo "UTC UTC") \ if [ $? = 1 -o $? = 255 ]; then rm -f $TMP/tz exit fi TIMEZONE="`cat $TMP/tz`" rm -f $TMP/tz setzone $TIMEZONE exit else ### ### use text prompts ### while [ 0 ]; do gettext "Would you like to configure your timezone" echo -n " ([y]es, [n]o)? " read TIMECONF; echo if [ "$TIMECONF" = "n" ]; then break fi gettext 'Select one of these timezones:' cat $ZONETAB | grep '/' | cut -f 3 | sort echo 'UTC' gettext "Select one of these timezones:" echo gettext "Type it at the prompt below exactly as it appears above. (NOTE: If you don't see your timezone, use \"timeconfig\" again after booting for the verbose list)" echo echo gettext "Timezone? " read TIMEZONE; echo if [ -n "$TIMEZONE" -a \ -r $T_PX/usr/share/zoneinfo/$TIMEZONE -o \ -r /var/log/mount/usr/share/zoneinfo/$TIMEZONE -o \ -L $T_PX/usr/share/zoneinfo/$TIMEZONE -o \ -L /var/log/mount/usr/share/zoneinfo/$TIMEZONE ]; then eval_gettext "Creating link from \$TIMEZONE to localtime in /etc..." echo setzone $TIMEZONE exit else echo eval_gettext "Timezone \$TIMEZONE could not be found. You may try again if you wish. Make sure you type the name exactly as it appears - this configuration script is case sensitive. Press [enter] to continue." echo read JUNK; fi done fi