summaryrefslogtreecommitdiff
path: root/recipes-core/systemd/timestamp-service/load-timestamp.sh
blob: b34c7ca5442662ce24204ede5f772b90cf78f8f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

# Set the system clock from hardware clock
# If the timestamp is 1 day or more recent than the current time,
# use the timestamp instead.
SYSTEMDATE=$(/bin/date -u "+%4Y%2m%2d%2H%2M")

TIMESTAMP=$(/bin/cat /etc/timestamp 2>/dev/null)

if [ ${TIMESTAMP} -gt $SYSTEMDATE ] 2>/dev/null ; then
	echo "Update systemtime from /etc/timestamp"
	/bin/date -u ${TIMESTAMP#????}${TIMESTAMP%????????}
fi

if [ "$1" = "--save" ] ; then
	/bin/date -u +%4Y%2m%2d%2H%2M > /etc/timestamp
fi