From 4e6abbb589babe7596a1213fc4e7e4bffbe1ffa3 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Thu, 12 Sep 2019 15:28:14 +0200 Subject: [PATCH] F #165: Support timedatectl in TIMEZONE context --- src/etc/one-context.d/loc-09-timezone | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/etc/one-context.d/loc-09-timezone b/src/etc/one-context.d/loc-09-timezone index 2586a3b..143ce0b 100755 --- a/src/etc/one-context.d/loc-09-timezone +++ b/src/etc/one-context.d/loc-09-timezone @@ -16,10 +16,15 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -if [ -z "$TIMEZONE" ]; then +if [ -z "${TIMEZONE}" ]; then exit 0 fi -if [ -f "/usr/share/zoneinfo/$TIMEZONE" ]; then - ln -sf "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime +if ! timedatectl set-timezone "${TIMEZONE}" 2>/dev/null; then + if [ -f "/usr/share/zoneinfo/${TIMEZONE}" ]; then + ln -sf "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime + else + echo "ERROR: Invalid timezone '${TIMEZONE}'" >&2 + exit 1 + fi fi