Check if date goes backwards

This commit is contained in:
Bob Mottram 2014-07-09 19:50:43 +01:00
parent a093437703
commit b2e25fca34
1 changed files with 26 additions and 1 deletions

View File

@ -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. 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 #+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 editor /etc/crontab
#+END_SRC #+END_SRC
Add the following near the top of the list of tasks. Add the following near the top of the list of tasks.
#+BEGIN_SRC: bash #+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 #+END_SRC
Save and exit. Save and exit.