]> CyberLeo.Net >> Repos - CDN/Mosi.git/blob - targets/amd64/NABIHI/config/patch/etc_rc.initdiskless-fix-clockskew.patch
targets/amd64/NABIHI: import
[CDN/Mosi.git] / targets / amd64 / NABIHI / config / patch / etc_rc.initdiskless-fix-clockskew.patch
1 --- etc/rc.initdiskless 2011-01-23 05:59:54.000000000 -0600
2 +++ etc/rc.initdiskless 2011-05-06 12:40:10.940259210 -0500
3 @@ -337,9 +337,30 @@
4  
5         # NFS remount
6         handle_remount $j
7 +
8 +       # <CyberLeo> Keep track of the most recent timestamp for clockskew detection
9 +       stamp="$(/usr/bin/stat -f %Um "$j")"
10 +       [ "${stamp}" -gt "${newest:-0}" ] && newest="${stamp}"
11 +       # </CyberLeo>
12      done
13  done
14  
15 +# <CyberLeo>
16 +# Check for clock skew, to make sure the local timestamp is newer than
17 +# the last saveconfig or the date of the image
18 +stamp="$(/usr/bin/stat -f %Um "/COPYRIGHT")"
19 +[ "${stamp}" -gt "${newest:-0}" ] && newest="${stamp}"
20 +if [ "${newest}" -gt "$(/bin/date +%s)" ]
21 +then
22 +       # Clock skew detected! Attempt to correct
23 +       correction="$(( ${newest} + 60 ))"
24 +       printf "Clock skew detected!\n" >&2
25 +       printf " Now (%s) is before newest (%s)\n" "$(/bin/date)" "$(/bin/date -jf %s "${newest}")" >&2
26 +       printf "Clock reset to %s\n" "$(/bin/date -f %s "${correction}")" >&2
27 +       printf "Run ntpd or ntpdate or manually set correct time!\n" >&2
28 +fi
29 +# </CyberLeo>
30 +
31  # - Create all required MFS filesystems and populate them from
32  #   our templates.  Support both a direct template and a dir.cpio.gz
33  #   archive.  Support dir.remove files containing a list of relative