#!/bin/sh

## live-config(7) - System Configuration Components
## Copyright (C) 2018 Bhushan Shah <bshah@kde.org>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.


set -e

Init ()
{
	# Checking if the hwclock date is higher then build_stamp
	builddate=$(date -d "`cat /.disk/build_stamp`" +%s)
	hwdate=$(date -d "`hwclock --get | cut -d ' ' -f 1`" +%s)

	if [ $hwdate -ge $builddate ];
	then
		exit 0
	fi
	echo -n " datetime"
}

Config ()
{
	# set time to that of build_stamp
	date -s "`cat /.disk/build_stamp`"
	hwclock --systohc

	# Creating state file
	touch /var/lib/live/config/datetime
}

Init
Config
