Ubuntu Upstart – Run Task After Networking Goes Up

Ubuntuubuntu-10.04upstart

I'm working on moving my current server setup to newer hardware, and migrating from ubuntu karmic koala to lucid lynx. Currently i'm using gw6c (compiled from the gogo6 website, as opposed to the version from the repositories) to get ipv6 access for my systems. On the karmic koala system, i used simple init.d script to get the ipv6 client started

 #! /bin/sh
/usr/local/gw6c/bin/gw6c -f /usr/local/gw6c/bin/gw6c.conf

I figured since this runs at any runlevel, it should translate to

respawn
console none

start on startup

stop on shutdown

script
exec /usr/local/gw6c/bin/gw6c -f /usr/local/gw6c/bin/gw6c.conf
emit free6_ipv6_started
end script

this works fine started from initctrl, but it apparently fails to start when it boots. – its status being stop/waiting. It works fine (and respawns) when started otherwise.Any ideas on where i'm going wrong, and what would be the appropriate 'start on' arguement?

EDIT: the exact error is 'init: gw6c main process (xxx) ended with status 8' followed by the process respawning , with xxx being a PID i suspect. I'm also half suspecting this is cause gw6c starts before networking does, and i need my eth0 up before gw6c is

Best Answer

Apparently

respawn
console none

start on (local-filesystems and net-device-up IFACE!=lo)
stop on [!12345]

script
chdir /usr/local/gw6c/bin/

exec /usr/local/gw6c/bin/gw6c 
end script

seems to work