Skip to content
Snippets Groups Projects
Commit b7cd6a3f authored by jow's avatar jow
Browse files

Add sysfixtime init script, replacement of luci_fixtime


Simply scan for the most recent file in /etc and set
system time to this file modification time if it's in the future
It allow some time dependent program to work immediatly
without waiting for ntpd to sync

v1: v2: bad approach
v3: simply scan /etc, thanks to Bastian Bittorf for the idea
v4: use sort -n, thanks to Catalin Patulea
v5: use [] instead of [[]], thanks to Andreas Mohr
v6: use openwrt style, thanks to Bastian Bittorf

Signed-off-by: default avatarEtienne CHAMPETIER <etienne.champetier@free.fr>

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@39422 3c298f89-4303-0410-b956-a3cf2f4a3e73
parent 25a825df
No related branches found
No related tags found
No related merge requests found
#!/bin/sh /etc/rc.common
# Copyright (C) 2013-2014 OpenWrt.org
START=00
boot() {
local curtime="$(date +%s)"
local maxtime="$(find /etc -type f -exec date +%s -r {} \; | sort -nr | head -n1)"
[ $curtime -lt $maxtime ] && \
date -s @$maxtime && \
logger -t sysfixtime -p daemon.notice "Time fixed"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment