upstart scripts: run a task after networking goes up

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


Place a script starting gw6c in

/etc/network/if-up.d

All scripts in that folder get run after an interface comes up. If you only want it run when eth0 comes up then edit the eth0 entry in

/etc/network/interfaces

and add a call to the script

iface eth0 inet dhcp
  up /etc/init.d/gw6c restart

I would also suggest adding pre-down scripts to shutdown the tunnel before the interface goes offline.

Once you do that and find an implementation that works, post it back here so I can use it. I've got gw6c on my laptop but I have been thus far to lazy to automate it.


Thank you "The Journeyman geek" :) You saved me a lot of time. I was fighting with /etc/init.d/gw6c script, trying some timings with "sysv-rc-conf -p" and wondering why it is not working (aka WTF?).

respawn
console none

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

script

exec /etc/init.d/gw6c start
end script

Slightly modified ("runlevel" and exec command) script did the job! :) :) :)