Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#154127 - 08/04/2003 10:18 @EXEC on network init?
tms13
old hand

Registered: 30/07/2001
Posts: 1115
Loc: Lochcarron and Edinburgh
Is it possible in Hijack to detect when the network interface is available and run a command at that time? I don't mind if I have to put a script in a /usr/local/etc/net-up.d directory or name it in the config.ini or anything else reasonable.

The reason I ask is that my player's clock gains seconds per day, and I want to run ntpdate whenever I boot with Ethernet plugged in. I tried writing
[hijack]
;@AC ;@EXEC /usr/local/bin/ntpdate -b timeserver
where timeserver is a machine with an NTP server, but this fails because my player is on DHCP and so has no network address until after the player has started:
8 Apr 17:05:57 ntpdate[10]: sendto(10.70.x.x): Network is unreachable
8 Apr 17:05:58 ntpdate[10]: sendto(10.70.x.x): Network is unreachable
8 Apr 17:05:59 ntpdate[10]: sendto(10.70.x.x): Network is unreachable
8 Apr 17:06:00 ntpdate[10]: sendto(10.70.x.x): Network is unreachable
8 Apr 17:06:01 ntpdate[1hijack_exec("/usr/local/bin/ntpdate -b 10.70.x.x"), rc=1 (ERROR)


I guess I could read up on binding commands to the Hijack menu, but then I'd have to manually invoke it every time, rather than it happening automatically.

Incidentally, couldn't find anything on EXEC/EXEC_ONCE in the Hijack FAQ - I think it's probably stable enough now, Loren?
_________________________
Toby Speight
030103016 (80GB Mk2a, blue)
030102806 (0GB Mk2a, blue)

Top
#154128 - 08/04/2003 10:24 Re: @EXEC on network init? [Re: tms13]
genixia
Carpal Tunnel

Registered: 08/02/2002
Posts: 3411
Odd. I currently still have the equivalent running from preinit and it works.
I can't understand why it's not working for you, I would have thought that the preinit called ntpdate would run earlier than the EXEC one. I usually see one 'network unreachable' before a sync.

Sanity check - does it work from a command line after boot?

Maybe you've got a slow dhcp server!
_________________________
Mk2a 60GB Blue. Serial 030102962 sig.mp3: File Format not Valid.

Top
#154129 - 08/04/2003 10:28 Re: @EXEC on network init? [Re: tms13]
cushman
veteran

Registered: 21/01/2002
Posts: 1380
Loc: Erie, CO
This is a feature that I have asked for before. Basically, you would like to have an EXEC_AFTER_PLAYER or such command to run some program after the player has started. I need the same thing, since my Palantir program needs to irattach the IrDA port after the player has loaded.

You could check out my script that comes with the empire (server side IrDA listener) package here. It's a hack to delay until the player has started, it just uses 'sleep' to wait for 10 seconds, then continues execution of the script. It's messy, but it works.
_________________________
Mark Cushman

Top
#154130 - 08/04/2003 10:31 Re: @EXEC on network init? [Re: cushman]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14478
Loc: Canada
EXEC after player won't solve this particular problem.

Rather, I believe his command needs to be modified run a script to poll for the network before running ntpdate.. Sometimes the network comes up very quickly (static settings), and sometimes very slowly (DHCP). On my network here, DHCP no longer functions at all from any of my Empegs (dunno why, they try and try, but seem to be ignoring the replies sent from the server).

Cheers

Top
#154131 - 08/04/2003 10:32 Re: @EXEC on network init? [Re: genixia]
tms13
old hand

Registered: 30/07/2001
Posts: 1115
Loc: Lochcarron and Edinburgh
What I have works if I quit and restart the player app from the serial terminal (or when I sync from JEmplode), but not if I reboot the player from Hijack or cold-boot by removing power. Like you, I think my player is too fast for our DHCP server.

Synchronising when I sync my music is a start, but I tend to go two months and then buy two dozen albums rather than the steady trickle that I used to (when I worked near town)...
_________________________
Toby Speight
030103016 (80GB Mk2a, blue)
030102806 (0GB Mk2a, blue)

Top
#154132 - 08/04/2003 10:38 Re: @EXEC on network init? [Re: mlord]
tms13
old hand

Registered: 30/07/2001
Posts: 1115
Loc: Lochcarron and Edinburgh
Something I should have asked - does @EXEC fork the child and abandon it, or does it wait() for it before returning from the syscall that's reading config.ini? If the latter, then a polling script would cause the player to hang indefinitely at home (where it's not on the network). My reading of the source is that it waits - right?
_________________________
Toby Speight
030103016 (80GB Mk2a, blue)
030102806 (0GB Mk2a, blue)

Top
#154133 - 08/04/2003 11:02 Re: @EXEC on network init? [Re: mlord]
cushman
veteran

Registered: 21/01/2002
Posts: 1380
Loc: Erie, CO
Ahh.. never mind then :^) I guess I didn't understand the problem fully.

One thing that I was thinking about though was a way to order the commands in config.ini. What if we used EXEC in config.ini to execute the player? If Hijack gets to the end of the EXEC list and there was no command to EXEC the player, then it would start up the player anyway. This would allow us to:

@EXEC "some program"
@EXEC "/path/to/player"
@EXEC "irattach /dev/ttyS2"

and no new commands would have to be added. Doesn't Hijack use the same exec function anyway to start the player?
_________________________
Mark Cushman

Top
#154134 - 08/04/2003 11:07 Re: @EXEC on network init? [Re: tms13]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14478
Loc: Canada
It hangs around and waits for it. But the script could fork off a child to do the polling while the main script exits.

Cheers

Top
#154135 - 08/04/2003 11:10 Re: @EXEC on network init? [Re: cushman]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14478
Loc: Canada
Actually, Hijack is running in the players context when it does all of the EXEC lines..

Top
#154136 - 24/07/2003 22:23 Re: @EXEC on network init? [Re: tms13]
drakino
carpal tunnel

Registered: 08/06/1999
Posts: 7868
Just wondering if you ever got this working. I'd like to add time syncing onto my empeg, and this would probably be the easiest way since I have an NTP server on my network.

Top
#154137 - 25/07/2003 13:54 Re: @EXEC on network init? [Re: drakino]
image
old hand

Registered: 28/04/2002
Posts: 770
Loc: Los Angeles, CA
well, the way i've done it was to make a bash script sleeping for 30 seconds while dhcp acquires an ip address.

Top
#154138 - 25/07/2003 17:19 Re: @EXEC on network init? [Re: drakino]
tms13
old hand

Registered: 30/07/2001
Posts: 1115
Loc: Lochcarron and Edinburgh
Yes, I did make it work.

I wrote a short script called /usr/local/bin/timesync.sh as follows:


#!/bin/sh
(sleep 10; /usr/local/bin/ntpdate $@) &


and put the following in config.ini:

;@AC ;@EXEC /usr/local/bin/timesync.sh 10.70.x.x 10.70.x.x 10.70.x.x


where the x.x are replaced with the correct values for the time servers here.
If I was doing it again, I wouldn't hard-code the 10 in the script, but would make that the first command-line argument:


#!/bin/sh
#untested!
DELAY=$1
shift
(sleep $DELAY; exec /usr/local/bin/ntpdate $@) &

_________________________
Toby Speight
030103016 (80GB Mk2a, blue)
030102806 (0GB Mk2a, blue)

Top
#154139 - 01/08/2003 06:43 Re: @EXEC on network init? [Re: tms13]
fede
journeyman

Registered: 31/01/2002
Posts: 89
Loc: Texas
I have gotten this approach to work now but I have a different problem. Apparently this is setting the UTC time on my player. How can I adjust an offset so that the clock displayed on my player appears correct for my time zone (US CST)?
_________________________
'a stock car stereo is a beautiful thing to waste' MKIIa 60gb MKIIa 20gb

Top
#154140 - 01/08/2003 08:26 Re: @EXEC on network init? [Re: fede]
mtempsch
pooh-bah

Registered: 02/06/2000
Posts: 1996
Loc: Gothenburg, Sweden
How can I adjust an offset so that the clock displayed on my player appears correct for my time zone (US CST)?

Settings->Timezone (on the player)

/Michael
_________________________
/Michael

Top