瀏覽代碼

Check if date goes backwards

Bob Mottram 11 年之前
父節點
當前提交
b2e25fca34
共有 1 個檔案被更改,包括 26 行新增1 行删除
  1. 26
    1
      beaglebone.txt

+ 26
- 1
beaglebone.txt 查看文件

1003
 If you get errors during the /configure/ stage then you may need to reboot so that some of the installed dependencies take effect.
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
 #+BEGIN_SRC: bash
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
 editor /etc/crontab
1031
 editor /etc/crontab
1007
 #+END_SRC
1032
 #+END_SRC
1008
 
1033
 
1009
 Add the following near the top of the list of tasks.
1034
 Add the following near the top of the list of tasks.
1010
 
1035
 
1011
 #+BEGIN_SRC: bash
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
 #+END_SRC
1038
 #+END_SRC
1014
 
1039
 
1015
 Save and exit.
1040
 Save and exit.