sysfixtime 530 B

12345678910111213141516171819202122232425
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2013-2014 OpenWrt.org
  3. START=00
  4. STOP=90
  5. RTC_DEV=/dev/rtc0
  6. HWCLOCK=/sbin/hwclock
  7. boot() {
  8. start && exit 0
  9. local curtime="$(date +%s)"
  10. local maxtime="$(find /etc -type f -exec date -r {} +%s \; | sort -nr | head -n1)"
  11. [ $curtime -lt $maxtime ] && date -s @$maxtime
  12. }
  13. start() {
  14. [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -f $RTC_DEV
  15. }
  16. stop() {
  17. [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -w -f $RTC_DEV && \
  18. logger -t sysfixtime "saved '$(date)' to $RTC_DEV"
  19. }