diff options
author | Dave Reisner <dreisner@archlinux.org> | 2011-09-04 15:41:53 -0400 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2011-09-25 00:55:35 +0200 |
commit | ae92346c03bc60578bfb5bddef9dbbf1b4d71460 (patch) | |
tree | 1964ba68087810d05f4f8e42c597570a91d15d9d /functions | |
parent | 872444291d3ab4cbeecd4a24216531564986a01c (diff) | |
download | initscripts-ae92346c03bc60578bfb5bddef9dbbf1b4d71460.tar.xz |
timezone: create /etc/localtime as a symlink
Abstract out timezone setting into its own function, passing
Country/Area as a parameter. Do some menial checking to make sure:
- the zonefile actually exists, erroring when it doesn't
- /etc/localtime is a symlink to the correct zoneinfo file, relinking
when it isn't.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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" |