[lxc-devel] [PATCH 2/4] Set timezone for new container if not previously defined.

Michael H. Warfield mhw at WittsEnd.com
Sat Mar 22 17:57:36 UTC 2014


Set timezone for new container if not previously defined.

If the container does not already contain an /etc/localtime
timezone definition, then copy a definition from the host to
the container.  This is often a symlink to an appropriate
system timezone definition files and is presumed to exist in

Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>
---
 templates/lxc-centos.in | 7 +++++++
 templates/lxc-fedora.in | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/templates/lxc-centos.in b/templates/lxc-centos.in
index 55e0531..f11a98c 100644
--- a/templates/lxc-centos.in
+++ b/templates/lxc-centos.in
@@ -203,6 +203,13 @@ configure_centos()
         )
     fi
 
+    # Set default localtime to the host localtime if not set...
+    if [ -e /etc/localtime -a ! -e ${rootfs_path}/etc/localtime ]
+    then
+        # if /etc/localtime is a symlink, this should preserve it.
+        cp -a /etc/localtime ${rootfs_path}/etc/localtime
+    fi
+
     # Deal with some dain bramage in the /etc/init.d/halt script.
     # Trim it and make it our own and link it in before the default
     # halt script so we can intercept it.  This also preventions package
diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in
index fa89121..f32ca53 100644
--- a/templates/lxc-fedora.in
+++ b/templates/lxc-fedora.in
@@ -176,6 +176,13 @@ configure_fedora()
         )
     fi
 
+    # Set default localtime to the host localtime if not set...
+    if [ -e /etc/localtime -a ! -e ${rootfs_path}/etc/localtime ]
+    then
+        # if /etc/localtime is a symlink, this should preserve it.
+        cp -a /etc/localtime ${rootfs_path}/etc/localtime
+    fi
+
     # Deal with some dain bramage in the /etc/init.d/halt script.
     # Trim it and make it our own and link it in before the default
     # halt script so we can intercept it.  This also preventions package
-- 
1.8.3.1


-- 
Michael H. Warfield (AI4NB) | (770) 978-7061 |  mhw at WittsEnd.com
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140322/1ee42416/attachment.pgp>


More information about the lxc-devel mailing list