upstart scripts: run a task after networking goes up
Solution 1
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
Solution 2
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.
Solution 3
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! :) :) :)
Related videos on Youtube
hey
Great and glorious alleged canine overlord at Super User Also, Singaporean geek, platform agnostic computer user and hardware enthusiast. In memory of Ash April 21 2005 to March 15 2021 No better friend or partner in crime could one expect. ♥️🇺🇦
Updated on September 17, 2022Comments
-
hey over 1 year
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
-
hey about 14 yearsThe former script i posted works pretty well- though i need to manually restart it, should my connection reset itself- this is for upstart, which is default on lucid lynx.
-
Andy Shellam about 14 yearsYeah I've just recently written a few that use net-device-up and net-device-down which work perfectly.
-
hey about 14 yearsi didn't find it anywhere in the documentation. someone on a local mailing list helped me out
-
Nathan Stocks over 11 yearsThis was exactly what I was looking for. It's still not in the upstart documentation anywhere that I could find.