NTP sync?

Posted by: Robotic

NTP sync? - 07/02/2008 15:49

After recent personal linux/empeg update lessons and successes I've been re-visiting my old thoughts about using empwake on my player. After updating the DST files I noticed that the empeg's clock was waay out, having been set once and only once a few (short) years ago.

I know in the Windows world there are tiny applications that will reach out across a network to sync up the system clock with NTP.

I did some (brief) surfing around for such things for linux and found some info.

I thought, "How cool would that be if the player sync'ed the clock on boot-up if there were a network around?"

Does anyone know what's involved in getting a linux machine to sync up with NTP and what issues might be involved in applying this to an empeg?
It could be a fun first experience for me, but I'd need a little hand-holding.
Posted by: mlord

Re: NTP sync? - 07/02/2008 15:58

Most of my players have this in their config.ini:

[hijack]
;@MENUEXEC Set_Date_Time /rdate -s 10.0.0.2 &>/dev/null

This allows me to reset the date/time at will from the Hijack menu, using my internal server (10.0.0.2) as a time reference.

I think the same thing might also work from EXEC_ONCE, except then it would need a script that could be more clever about waiting for the network to come before issuing the command.

Cheers
Posted by: wfaulk

Re: NTP sync? - 07/02/2008 15:59

There are two different ways that you can synchronize your time on a Unix machine. One way is a daemon that runs and constantly checks remote time servers for the current time, modifying the local clock frequently. Another is a simple program that just checks once and sets the time.

I think that the first is overkill for a system that isn't likely to be up for a long period of time. The second is pretty easy. Just get an ntpdate binary and have it run upon boot. It should be pretty easy to check to see if the network is up by searching the output of 'ifconfig eth0' for 'UP'.
Posted by: mlord

Re: NTP sync? - 07/02/2008 16:05

Originally Posted By: wfaulk
It should be pretty easy to check to see if the network is up by searching the output of 'ifconfig eth0' for 'UP'.

Of course that does require also hunting down and installing ifconfig. And the script should be slightly more clever to wait a few seconds for the network if it is not up, whilst not holding up the player software during the process.

Cheers
Posted by: wfaulk

Re: NTP sync? - 07/02/2008 16:10

There's no ifconfig on the player? Argh. How does it set IP addresses?

You might be able to figure it out by parsing /proc/net/route?
Posted by: peter

Re: NTP sync? - 07/02/2008 16:29

Quote:
There's no ifconfig on the player? Argh. How does it set IP addresses?

"There's no Winamp on the player? Argh. How does it play MP3s?"

wink

The player code contains the same syscalls that ifconfig would make. (See, for instance, Stevens, UNPvol1, sec16.7.)

Peter
Posted by: wfaulk

Re: NTP sync? - 07/02/2008 16:52

Yeah, I figured. I just wanted to make sure that Mark wasn't mistaken by forcing someone to look.
Posted by: Robotic

Re: NTP sync? - 07/02/2008 17:15

Originally Posted By: mlord
Most of my players have this in their config.ini:

[hijack]
;@MENUEXEC Set_Date_Time /rdate -s 10.0.0.2 &>/dev/null

This allows me to reset the date/time at will from the Hijack menu, using my internal server (10.0.0.2) as a time reference.

I think the same thing might also work from EXEC_ONCE, except then it would need a script that could be more clever about waiting for the network to come before issuing the command.

Cheers

Ah- interesting! Perhaps I should just learn a bit more about setting up my home PC as a time server for the empeg to query when instructed to via your Hijack menu.
Hmm... it's not automatic, but sounds simple enough.

How do other applications 'reach out and check'? I see autohijack could (once upon a time) do something like that. I suppose most folks use jEmplode for updating Hijack these days...

Setting the empeg clock could also be done externally somehow, I guess... a batch file that talks via ftp or (dreaming now) an adjunct to (j)Emplode?
Posted by: Robotic

Re: NTP sync? - 07/02/2008 17:39

Whoohoo!
Posted by: Robotic

Re: NTP sync? - 12/02/2008 15:25

I've been meaning to play around with ntpdate, rdate, and ifconfig one evening soon. I've done some reading about them (mostly what's available are the help files).
I figure I can't really screw anything up, so long as I don't delete anything from the empeg that I'm not supposed to. lol

/babe in the linux woods
Posted by: Robotic

Re: NTP sync? - 14/02/2008 02:37

Hmm...
http://packages.debian.org/etch/ntpdate
It's the 'arm' package, I'm supposing...
...or should I not be looking at Debian 'packages'?

Hmm, hmm...
http://www.eecis.udel.edu/~ntp/ntp_spool/html/ntpdate.html
It says
Quote:
-t timeout
Specify the maximum time waiting for a server response as the value timeout, in seconds and fraction. The value is is rounded to a multiple of 0.2 seconds. The default is 1 second, a value suitable for polling across a LAN.

Does that mean that all other boot-up actions are delayed by this value if no server is found?
I'm assuming that ntpdate is not smart enough to give up immediately if it doesn't see a network... which is why Bitt and Mark are leaning on ifconfig to find that out...
Posted by: Roger

Re: NTP sync? - 14/02/2008 06:08

Originally Posted By: Robotic
...or should I not be looking at Debian 'packages'?


Debian packages are fine. Etch might be a bit new. You want ARM-compiled potato packages, if I recall correctly.

The empeg doesn't have dpkg, so you'll have to unpack and install the binaries yourself. You'll find instructions on how to do this a short way down the Lazy Bastard's Guide to Cloning your empegs.

Posted by: peter

Re: NTP sync? - 14/02/2008 09:31

Originally Posted By: Roger
Etch might be a bit new.

Heh, there can't be many places where you can hear that said with a straight face!

Peter
Posted by: Robotic

Re: NTP sync? - 14/02/2008 15:45

Thanks, Roger.
LOL - It took me a second to figure out what you meant by a 'potato package'. (lumpy pants jokes aside)
I can't find Debian references to ntp packages for anything earlier than sarge.
Posted by: mlord

Re: NTP sync? - 14/02/2008 16:04

Debian Potato (aka. v2.2) is available here.
Posted by: Robotic

Re: NTP sync? - 14/02/2008 16:27

Originally Posted By: mlord
Debian Potato is available here.

Ah- Thanks, Mark! Yes, I see nptdate in the net directory. Great!
Posted by: Robotic

Re: NTP sync? - 15/02/2008 03:11

The readme file says
Quote:
Note that ntpdate is run during system startup. If you specify
servers that are not reachable at boot time, you'll have to wait for
ntpdate to time out looking for them. In this case, you might want to
consider editing /etc/init.d/ntpdate to comment out the invocation
there, and add a fragment to your ppp/isdn/whatever startup scripts
instead.

Also, note that ntpdate is *not* really intended to be used by servers with
good network connectivity. The 'ntp' package, which provides a persistent
daemon that does a better job of keeping system time than even a cron'ed
invocation of ntpdate, is a better choice for systems with good network
connectivity. It may be useful to also have ntpdate on systems that run
ntp, so that the clock is warped to approximately the right time at boot
before ntp is launched, but there are options to ntpd that can be added to
the init.d script for the ntp package that can accomplish much the same
thing.

Ok, off to read Roger's site...
Posted by: Roger

Re: NTP sync? - 15/02/2008 06:07

Originally Posted By: Robotic
The readme file says
Quote:
Note that ntpdate is run during system startup.



Also, the empeg doesn't have init scripts, so you'll have to use Hijack's @EXEC stuff. I don't know if that's asynchronous or not.

I've got ntpdate on my empeg, but it runs when I drop to a shell prompt over serial, which I used to do regularly. I don't remember how the hell I set that up though. I'll dig out a serial cable and take a look later...
Posted by: mlord

Re: NTP sync? - 15/02/2008 13:14

I just run it on command from the Hijack menu. Full control over it that way, and no serial cable required.

Cheers
Posted by: Robotic

Re: NTP sync? - 15/02/2008 15:14

My first task will be to move the files into the correct locations.
Baby steps, I know. lol

After that, I'll work out running it from a prompt, then the Hijack exec stuff.
Should be fun. wink
Posted by: Robotic

Re: NTP sync? - 21/02/2008 04:12

You people are too polite.

"Silly n00b, go search the BBS!"

=facepalm=
*sigh*