[lxc-devel] [lxc/master] Timezone inside the container is not the same as the host
thtanaka on Github
lxc-bot at linuxcontainers.org
Fri Mar 25 17:05:11 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 452 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160325/14eaef89/attachment.bin>
-------------- next part --------------
From 710a25539eebf98c0460b2d791e78b74d7e47935 Mon Sep 17 00:00:00 2001
From: Thomas Tanaka <thomas.tanaka at oracle.com>
Date: Fri, 25 Mar 2016 09:53:33 -0700
Subject: [PATCH] Timezone inside the container is not the same as the host
In OL6, it is missing /etc/sysconfig/clock
Tested-by: Deepak Patel <deepak.patel at oracle.com>
Signed-off-by: Thomas Tanaka <thomas.tanaka at oracle.com>
---
templates/lxc-oracle.in | 25 +++++++++++++++++++++++++
templates/lxc-sparclinux.in | 9 +++++++++
2 files changed, 34 insertions(+)
diff --git a/templates/lxc-oracle.in b/templates/lxc-oracle.in
index fbd0fd2..d5a1514 100644
--- a/templates/lxc-oracle.in
+++ b/templates/lxc-oracle.in
@@ -440,6 +440,31 @@ EOF
# start with a clean /var/log/messages
rm -f $container_rootfs/var/log/messages
+ # set initial timezone as on host
+ if [ -f /etc/sysconfig/clock ]; then
+ . /etc/sysconfig/clock
+ if [ $container_release_major = "5" -o $container_release_major = "6" ]; then
+ echo ZONE=$ZONE > $container_rootfs/etc/sysconfig/clock
+ chroot $container_rootfs tzdata-update
+ else
+ ZONE="${ZONE// /_}"
+ chroot $container_rootfs ln -sf ../usr/share/zoneinfo/$ZONE /etc/localtime
+ fi
+ else
+ ZONE=`readlink /etc/localtime | sed -s "s/\.\.\/usr\/share\/zoneinfo\///g"`
+ if [ "$ZONE" ]; then
+ if [ $container_release_major = "5" -o $container_release_major = "6" ]; then
+ echo ZONE=$ZONE > $container_rootfs/etc/sysconfig/clock
+ chroot $container_rootfs tzdata-update
+ else
+ # if /etc/localtime is a symlink, this should preserve it.
+ cp -a /etc/localtime $container_rootfs/etc/localtime
+ fi
+ else
+ echo "Timezone in container is not configured. Adjust it manually."
+ fi
+ fi
+
# add oracle user, set root password
chroot $container_rootfs useradd -m -s /bin/bash oracle
echo "oracle:oracle" | chroot $container_rootfs chpasswd
diff --git a/templates/lxc-sparclinux.in b/templates/lxc-sparclinux.in
index 5dbca42..cfb893a 100644
--- a/templates/lxc-sparclinux.in
+++ b/templates/lxc-sparclinux.in
@@ -291,6 +291,15 @@ EOF
# start with a clean /var/log/messages
rm -f $container_rootfs/var/log/messages
+ # set initial timezone as on host
+ if [ -f /etc/sysconfig/clock ]; then
+ . /etc/sysconfig/clock
+ echo ZONE=$ZONE > $container_rootfs/etc/sysconfig/clock
+ chroot $container_rootfs tzdata-update
+ else
+ echo "Timezone in container is not configured. Adjust it manually."
+ fi
+
# add oracle user, set root password
chroot $container_rootfs useradd -m -s /bin/bash oracle
echo "oracle:oracle" | chroot $container_rootfs chpasswd
More information about the lxc-devel
mailing list