Upstart network connection event?
S. Zeier
s.zeier at gmx.de
Sat Jul 31 15:27:04 UTC 2010
Hi,
on my Ubuntu 10.04 LTS machine I had the same problem...
One possible solution might look like this:
The event to be used in your upstart script is
...
start on net-device-up
...
Event "net-device-up" is emitted by upstart script
/etc/network/if-up.d/upstart
and provides shell variable IFACE you can use
to trigger interface dependent actions - in case your host
has several network cards equipped.
Example:
...
start on net-device-up
...
script
if [ "$IFACE" = eth0 ]
then
# do this stuff
else
if [ "$IFACE" = eth1 ]
then
# do that stuff
fi
end script
Hope this helps...
Cheers!
> Hi all,
>
> I'm writing an Upstart script which would run in the event a network cable
> is connected (i.e., the network interface get's an IP address.) However, I
> am having trouble figuring out which event I should use for the 'start on'
> directive.
>
> Output of 'initctl list | grep network' shows the following networking
> related events:
>
> network-manager start/running, process 843
> network-interface (lo) start/running
> network-interface (eth0) start/running
> network-interface (wlan0) start/running
> network-interface-security start/running
> networking stop/waiting
>
> network-manager starts at boot and doesn't change after that if the
> cable is
> disconnected so taht won't work. Also the network-interface* events stay
> started once the system is booted.
>
> The description for 'networking' states "This task causes virtual network
> devices that do not have an associated kernel object to be started on
> boot."
> So I'm not sure that is an option.
>
> I'm thinking perhaps there is a udevmonitor event I can use, but again, I'm
> not sure which one?
>
> Does anyone have any experience with building scripts like this?
More information about the ubuntu-users
mailing list