Message ID | 1450344965-96301-1-git-send-email-openwrt@daniel.thecshore.com |
---|---|
State | Changes Requested |
Headers | show |
* openwrt@daniel.thecshore.com <openwrt@daniel.thecshore.com> [17.12.2015 10:39]: > From: Daniel Dickinson <openwrt@daniel.thecshore.com> > > On systems that have an RTC prefer it to the file-based > time fixup (i.e. use hwclock when there is a permanent > clock instead of the faked up time logic that is needed > when there is not RTC). whats the difference between both mails? also i suggest for the future: if [ -e /dev/rtc ]; then ... else ... fi instead of testing the opposite. bye, bastian
diff --git a/package/base-files/files/etc/init.d/sysfixtime b/package/base-files/files/etc/init.d/sysfixtime index 4010e06..e1e6724 100755 --- a/package/base-files/files/etc/init.d/sysfixtime +++ b/package/base-files/files/etc/init.d/sysfixtime @@ -2,10 +2,27 @@ # Copyright (C) 2013-2014 OpenWrt.org START=00 +STOP=90 boot() { - local curtime="$(date +%s)" - local maxtime="$(find /etc -type f -exec date -r {} +%s \; | sort -nr | head -n1)" - [ $curtime -lt $maxtime ] && date -s @$maxtime + if [ ! -e /dev/rtc ]; then + local curtime="$(date +%s)" + local maxtime="$(find /etc -type f -exec date -r {} +%s \; | sort -nr | head -n1)" + [ $curtime -lt $maxtime ] && date -s @$maxtime + else + hwclock -s + fi +} + +start() { + if [ -e /dev/rtc ]; then + hwclock -s + fi +} + +stop() { + if [ -e /dev/rtc ]; then + hwclock -w + fi }