1
|
#!/bin/sh
|
2
|
#
|
3
|
# rc.checkclock
|
4
|
#
|
5
|
# part of pfSense (https://www.pfsense.org)
|
6
|
# Copyright (c) 2022 Rubicon Communications, LLC (Netgate)
|
7
|
# All rights reserved.
|
8
|
#
|
9
|
# originally based on m0n0wall (http://neon1.net/m0n0wall)
|
10
|
# Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11
|
# All rights reserved.
|
12
|
#
|
13
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
14
|
# you may not use this file except in compliance with the License.
|
15
|
# You may obtain a copy of the License at
|
16
|
#
|
17
|
# http://www.apache.org/licenses/LICENSE-2.0
|
18
|
#
|
19
|
# Unless required by applicable law or agreed to in writing, software
|
20
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
21
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
22
|
# See the License for the specific language governing permissions and
|
23
|
# limitations under the License.
|
24
|
|
25
|
get_best_time() {
|
26
|
if [ -e ${2} ]; then
|
27
|
FILETIME=`/usr/bin/stat -t "%Y%m%d%H%M" -f '%Sm' ${2}`
|
28
|
if [ ${1} -lt ${FILETIME} ]; then
|
29
|
echo "${FILETIME}"
|
30
|
return 0
|
31
|
fi
|
32
|
fi
|
33
|
|
34
|
echo "${1}"
|
35
|
return 0
|
36
|
}
|
37
|
|
38
|
BESTTIME=0
|
39
|
FILELIST="/conf/config.xml /conf.default/config.xml /var/log/system.log /conf/rules.debug.old /cf/conf/RAM_Disk_Store /var/db/ntpd.drift /conf/upgrade_log.txt"
|
40
|
for filename in ${FILELIST}
|
41
|
do
|
42
|
BESTTIME=$( get_best_time ${BESTTIME} ${filename} )
|
43
|
done
|
44
|
|
45
|
CURRENTTIME=`/bin/date "+%Y%m%d%H%M"`
|
46
|
|
47
|
if [ ${CURRENTTIME} -lt ${BESTTIME} ]; then
|
48
|
echo "Current time is older than key file time, using file time instead."
|
49
|
/bin/date ${BESTTIME} 2>/dev/null >/dev/null
|
50
|
fi
|