From 290afe72d53b5e38c3781934e23a676a3c1986e5 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 1 Mar 2016 12:30:31 -0500 Subject: 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 due to an old bug in Ubuntu, symlink should be preferred. LP: #1543025 --- ChangeLog | 2 ++ cloudinit/distros/__init__.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b31148ac..2f1f9f87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -81,6 +81,8 @@ - lxd: add support for setting up lxd using 'lxd init' (LP: #1522879) - Add Image Customization Parser for VMware vSphere Hypervisor Support. [Sankar Tanguturi] + - timezone: use a symlink rather than copy for /etc/localtime + unless it is already a file (LP: #1543025). 0.7.6: - open 0.7.6 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 -- cgit v1.2.3