#!/bin/sh
set -e

ORIG_TZ=`grep -v '^#' /etc/timezone`

# should activate daemon and work
STATUS=`timedatectl`
echo "$STATUS" | grep -q "Local time:"

# change timezone
OUT=`timedatectl set-timezone Europe/Moscow 2>&1`
[ -z "$OUT" ]
[ "`cat /etc/timezone`" = "Europe/Moscow" ]
STATUS=`timedatectl`
echo "$STATUS" | grep -q "Time.*zone: Europe/Moscow (MSK, +"

# reset timezone to original
OUT=`timedatectl set-timezone $ORIG_TZ 2>&1`
[ -z "$OUT" ]
[ "`cat /etc/timezone`" = "$ORIG_TZ" ]
