Comment 1 for bug 998388

Revision history for this message
Clint Byrum (clint-fewbar) wrote : Re: [Bug 998388] Re: emmit signal when network-manager deconfigures interface

Excerpts from muzzol's message of Sat May 12 14:38:54 UTC 2012:
> ** Description changed:
>
> I want to execute a script when network (any interface) goes up and when
> goes down (with parameters).
>
> I've found easy to trigger first part with
>
> - start on (net-device-up IFACE!=lo)
> +     start on (net-device-up IFACE!=lo)
>
> but didn't manage to found an easy way to trigger either net-device-
> down, net-device-remove(d) , deconfiguring-networking
> -
>
> my job loks like this:
>
> ##################################################################
> description "network test"
>
> start on (net-device-up IFACE!=lo)
> # stop on ((net-device-down IFACE!=lo) or deconfiguring-networking)
> stop on net-device-removed IFACE!=lo
>
> pre-start exec /opt/test.sh start "$UPSTART_JOB - EVENT:
> $UPSTART_EVENTS"
>
> post-stop exec /opt/test.sh stop "$UPSTART_JOB - EVENT:
> $UPSTART_STOP_EVENTS"
>

net-device-down should be emitted whenever an interface goes down:

$ cat !$
cat /etc/network/if-down.d/upstart
#!/bin/sh

set -e

initctl emit -n net-device-down \
    "IFACE=$IFACE" \
    "LOGICAL=$LOGICAL" \
    "ADDRFAM=$ADDRFAM" \
    "METHOD=$METHOD"