aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--functions17
-rwxr-xr-xrc.sysinit4
2 files changed, 18 insertions, 3 deletions
diff --git a/functions b/functions
index f550642..b85de46 100644
--- a/functions
+++ b/functions
@@ -369,6 +369,23 @@ read_crypttab() {
return $failed
}
+set_timezone() {
+ local tz=$1 zonefile=/usr/share/zoneinfo/$tz
+
+ [[ $tz ]] || return 1
+
+ if [[ ! -e $zonefile ]]; then
+ printf "error: \`%s' is not a valid timezone\n" "$tz"
+ return 1
+ fi
+
+ if [[ -L /etc/localtime && /etc/localtime -ef $zonefile ]]; then
+ return 0
+ fi
+
+ ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime
+}
+
# Filesystem functions
# These can be overridden/reused for customizations like shutdown/loop-fsck.
NETFS="nfs,nfs4,smbfs,cifs,codafs,ncpfs,shfs,fuse,fuseblk,glusterfs,davfs,fuse.glusterfs"
diff --git a/rc.sysinit b/rc.sysinit
index 9f215c4..2a7db8b 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -221,9 +221,7 @@ run_hook sysinit_postmount
status "Activating Swap" swapon -a
-[[ $TIMEZONE ]] &&
- status "Configuring Time Zone" \
- cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
+[[ $TIMEZONE ]] && status "Configuring Time Zone" set_timezone "$TIMEZONE"
RANDOM_SEED=/var/lib/misc/random-seed
[[ -f $RANDOM_SEED ]] &&