2014-01-29 13:17:03 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
# Copyright (C) 2013-2014 OpenWrt.org
|
|
|
|
|
|
|
|
START=00
|
2016-02-08 08:25:53 +00:00
|
|
|
STOP=90
|
|
|
|
|
|
|
|
RTC_DEV=/dev/rtc0
|
|
|
|
HWCLOCK=/sbin/hwclock
|
2014-01-29 13:17:03 +00:00
|
|
|
|
|
|
|
boot() {
|
2016-02-08 08:25:53 +00:00
|
|
|
start && exit 0
|
|
|
|
|
2016-05-05 11:34:49 +00:00
|
|
|
local maxtime="$(maxtime)"
|
2014-01-29 13:17:03 +00:00
|
|
|
local curtime="$(date +%s)"
|
2014-06-02 12:42:37 +00:00
|
|
|
[ $curtime -lt $maxtime ] && date -s @$maxtime
|
2014-01-29 13:17:03 +00:00
|
|
|
}
|
|
|
|
|
2016-02-08 08:25:53 +00:00
|
|
|
start() {
|
|
|
|
[ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -f $RTC_DEV
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
[ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -w -f $RTC_DEV && \
|
|
|
|
logger -t sysfixtime "saved '$(date)' to $RTC_DEV"
|
|
|
|
}
|
2016-05-05 11:34:49 +00:00
|
|
|
|
|
|
|
maxtime() {
|
|
|
|
local file newest
|
|
|
|
|
2016-06-16 09:50:36 +00:00
|
|
|
for file in $( find /etc -type f ) ; do
|
2016-05-19 15:57:19 +00:00
|
|
|
[ -z "$newest" -o "$newest" -ot "$file" ] && newest=$file
|
2016-05-05 11:34:49 +00:00
|
|
|
done
|
|
|
|
[ "$newest" ] && date -r "$newest" +%s
|
|
|
|
}
|