#!/bin/bash

# Call yast to do the system config
yast timezone

# Get the correct timezone string
TIMEZONE=`timedatectl | grep 'Time zone' | xargs | cut -d ' ' -f3`

# And make changes to php and /etc/sysconfig/clock
if [ -f "/etc/php7/cli/php.ini" ]; then
	sed -i "/date.timezone = /c\date.timezone = '$TIMEZONE'" /etc/php7/cli/php.ini
fi
sed -i "/date.timezone = /c\date.timezone = '$TIMEZONE'" /etc/php7/apache2/php.ini
echo "DEFAULT_TIMEZONE=\"$TIMEZONE\"" > /etc/sysconfig/clock
echo ""
echo " Time Zone set to: $TIMEZONE"
echo " A reboot might be required for changes to take effect."
echo ""
