Explorar el Código

Check if date goes backwards

Bob Mottram hace 11 años
padre
commit
b2e25fca34
Se han modificado 1 ficheros con 26 adiciones y 1 borrados
  1. 26
    1
      beaglebone.txt

+ 26
- 1
beaglebone.txt Ver fichero

@@ -1003,13 +1003,38 @@ make install
1003 1003
 If you get errors during the /configure/ stage then you may need to reboot so that some of the installed dependencies take effect.
1004 1004
 
1005 1005
 #+BEGIN_SRC: bash
1006
+editor /usr/bin/updatedate
1007
+#+END_SRC
1008
+
1009
+Add the following:
1010
+
1011
+#+BEGIN_SRC: bash
1012
+#!/bin/bash
1013
+
1014
+TIMESOURCE=www.ptb.de
1015
+LOGFILE=/var/log/tlsdate.log
1016
+DATE_BEFORE=$(date)
1017
+YEAR_BEFORE=$(echo $DATE_BEFORE | awk -F ' ' '{print $6}')
1018
+/usr/bin/timeout 3 tlsdate -l -t -H $TIMESOURCE -p 443
1019
+DATE_AFTER=$(date)
1020
+YEAR_AFTER=$(echo $DATE_AFTER | awk -F ' ' '{print $6}')
1021
+if [ "$YEAR_AFTER" -lt "$YEAR_BEFORE" ]; then
1022
+	echo "Incorrect date: $DATE_BEFORE -> $DATE_AFTER" >> $LOGFILE
1023
+	date -s "DATE_BEFORE"
1024
+fi
1025
+#+END_SRC
1026
+
1027
+Save and exit.
1028
+
1029
+#+BEGIN_SRC: bash
1030
+chmod +x /usr/bin/updatedate
1006 1031
 editor /etc/crontab
1007 1032
 #+END_SRC
1008 1033
 
1009 1034
 Add the following near the top of the list of tasks.
1010 1035
 
1011 1036
 #+BEGIN_SRC: bash
1012
-*/15           * *   *   *   root /usr/bin/timeout 3 tlsdate -l -t -H www.ptb.de -p 443
1037
+*/15           * *   *   *   root /usr/bin/updatedate
1013 1038
 #+END_SRC
1014 1039
 
1015 1040
 Save and exit.