From b2e25fca345cba75e1536ace677f75819266a53b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 9 Jul 2014 19:50:43 +0100 Subject: [PATCH] Check if date goes backwards --- beaglebone.txt | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/beaglebone.txt b/beaglebone.txt index 35072529..723722f1 100644 --- a/beaglebone.txt +++ b/beaglebone.txt @@ -1003,13 +1003,38 @@ make install If you get errors during the /configure/ stage then you may need to reboot so that some of the installed dependencies take effect. #+BEGIN_SRC: bash +editor /usr/bin/updatedate +#+END_SRC + +Add the following: + +#+BEGIN_SRC: bash +#!/bin/bash + +TIMESOURCE=www.ptb.de +LOGFILE=/var/log/tlsdate.log +DATE_BEFORE=$(date) +YEAR_BEFORE=$(echo $DATE_BEFORE | awk -F ' ' '{print $6}') +/usr/bin/timeout 3 tlsdate -l -t -H $TIMESOURCE -p 443 +DATE_AFTER=$(date) +YEAR_AFTER=$(echo $DATE_AFTER | awk -F ' ' '{print $6}') +if [ "$YEAR_AFTER" -lt "$YEAR_BEFORE" ]; then + echo "Incorrect date: $DATE_BEFORE -> $DATE_AFTER" >> $LOGFILE + date -s "DATE_BEFORE" +fi +#+END_SRC + +Save and exit. + +#+BEGIN_SRC: bash +chmod +x /usr/bin/updatedate editor /etc/crontab #+END_SRC Add the following near the top of the list of tasks. #+BEGIN_SRC: bash -*/15 * * * * root /usr/bin/timeout 3 tlsdate -l -t -H www.ptb.de -p 443 +*/15 * * * * root /usr/bin/updatedate #+END_SRC Save and exit.