diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-03-01 12:48:11 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-03-01 12:48:11 -0500 |
commit | 97efb9d48197d7098f1abe2ee519418afbe6aec5 (patch) | |
tree | d17d8ded09d9274c40f652d8bc3d4fd0d6449cae /cloudinit | |
parent | f0e26abe896318819a6b568dd72e9974b53928c8 (diff) | |
parent | 290afe72d53b5e38c3781934e23a676a3c1986e5 (diff) | |
download | vyos-cloud-init-97efb9d48197d7098f1abe2ee519418afbe6aec5.tar.gz vyos-cloud-init-97efb9d48197d7098f1abe2ee519418afbe6aec5.zip |
timezone: use a symlink when updating /etc/localtime
Unless /etc/localtime is an existing file and not a symlink,
then we will symlink instead of copying the tz_file to /etc/localtime.
The copy was how older versions of Ubuntu handled this.
Those versions should have a file /etc/localtime . When the symlink
is preferred, then it should already exist in the image.
LP: #1543025
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/distros/__init__.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 71884b32..8167c594 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -897,5 +897,9 @@ def set_etc_timezone(tz, tz_file=None, tz_conf="/etc/timezone", util.write_file(tz_conf, str(tz).rstrip() + "\n") # This ensures that the correct tz will be used for the system if tz_local and tz_file: - util.copy(tz_file, tz_local) + # use a symlink if there exists a symlink or tz_local is not present + if os.path.islink(tz_local) or not os.path.exists(tz_local): + os.symlink(tz_file, tz_local) + else: + util.copy(tz_file, tz_local) return |