aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2014-01-29 13:17:03 +0000
committerJo-Philipp Wich <jow@openwrt.org>2014-01-29 13:17:03 +0000
commitb187527a51e58d91cd71759e0f325f1e268242ac (patch)
tree6e2d38711b1723d6090945741bef8ddaab64c80e /package/base-files/files
parente2dcb6b7ecfeb60567c6b39646e444997c903286 (diff)
downloadmaster-187ad058-b187527a51e58d91cd71759e0f325f1e268242ac.tar.gz
master-187ad058-b187527a51e58d91cd71759e0f325f1e268242ac.tar.bz2
master-187ad058-b187527a51e58d91cd71759e0f325f1e268242ac.zip
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: Etienne CHAMPETIER <etienne.champetier@free.fr> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@39422 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/base-files/files')
-rwxr-xr-xpackage/base-files/files/etc/init.d/sysfixtime13
1 files changed, 13 insertions, 0 deletions
diff --git a/package/base-files/files/etc/init.d/sysfixtime b/package/base-files/files/etc/init.d/sysfixtime
new file mode 100755
index 0000000000..525d765758
--- /dev/null
+++ b/package/base-files/files/etc/init.d/sysfixtime
@@ -0,0 +1,13 @@
+#!/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"
+}
+