Phil Pennock <[email protected]> writes:

> For context, I'm currently running OpenWRT; attached is the
> /etc/init.d/ntpdate which I'm using. It relies upon having Python and
> dig installed, as I haven't gotten around to building a small C
> utility to do just this task, but perhaps the approach is useful
> enough that someone else might do so?

A functionality similar to this is already implemented in openwrt and
runs as the first thing on boot. It finds the newest file in /etc and
sets the system time to that:

# cat /etc/init.d/sysfixtime 
#!/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"
}


This works well enough that I haven't had any time problems in recent
memory. However I tend to build my images minutes before flashing them,
so for someone downloading an image off somewhere, the ntp lookup is
obviously needed.

I do believe it would be feasible to include your script without the
preseed part pretty much as-is? It adds a dependency on dig, but I guess
that is not unreasonable (certainly not for cerowrt, but maybe for
openwrt default). The ntpdate dependency can probably be gotten away
with by substituting an appropriate ntpd -q command...

-Toke

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Cerowrt-devel mailing list
[email protected]
https://lists.bufferbloat.net/listinfo/cerowrt-devel

Reply via email to