223.2.16
by Scott Moser
* New upstream snapshot. |
1 |
# in a lxc container, events for network interfaces do not |
2 |
# get created or may be missed. This helps cloud-init-nonet along |
|
3 |
# by emitting those events if they have not been emitted. |
|
4 |
||
5 |
start on container |
|
6 |
stop on static-network-up |
|
7 |
task
|
|
8 |
||
9 |
emits net-device-added |
|
10 |
||
11 |
console output |
|
12 |
||
13 |
script
|
|
14 |
# if we are inside a container, then we may have to emit the ifup |
|
15 |
# events for 'auto' network devices. |
|
16 |
set -f |
|
17 |
||
18 |
# from /etc/network/if-up.d/upstart |
|
19 |
MARK_DEV_PREFIX="/run/network/ifup." |
|
20 |
MARK_STATIC_NETWORK_EMITTED="/run/network/static-network-up-emitted" |
|
21 |
# if the all static network interfaces are already up, nothing to do |
|
22 |
[ -f "$MARK_STATIC_NETWORK_EMITTED" ] && exit 0 |
|
23 |
||
1.1.41
by Scott Moser
Import upstream version 0.7.2~bzr795 |
24 |
# ifquery will exit failure if there is no /run/network directory. |
25 |
# normally that would get created by one of network-interface.conf |
|
26 |
# or networking.conf. But, it is possible that we're running |
|
27 |
# before either of those have.
|
|
28 |
mkdir -p /run/network
|
|
29 |
||
223.2.16
by Scott Moser
* New upstream snapshot. |
30 |
# get list of all 'auto' interfaces. if there are none, nothing to do. |
31 |
auto_list=$(ifquery --list --allow auto 2>/dev/null) || :
|
|
32 |
[ -z "$auto_list" ] && exit 0
|
|
33 |
set -- ${auto_list}
|
|
34 |
[ "$*" = "lo" ] && exit 0
|
|
35 |
||
36 |
# we only want to emit for interfaces that do not exist, so filter
|
|
37 |
# out anything that does not exist.
|
|
38 |
for iface in "$@"; do
|
|
39 |
[ "$iface" = "lo" ] && continue
|
|
40 |
# skip interfaces that are already up
|
|
41 |
[ -f "${MARK_DEV_PREFIX}${iface}" ] && continue
|
|
42 |
||
43 |
if [ -d /sys/net ]; then
|
|
44 |
# if /sys is mounted, and there is no /sys/net/iface, then no device
|
|
45 |
[ -e "/sys/net/$iface" ] && continue
|
|
46 |
else
|
|
47 |
# sys wasn't mounted, so just check via 'ifconfig' |
|
48 |
ifconfig "$iface" >/dev/null 2>&1 || continue |
|
49 |
fi
|
|
50 |
initctl emit --no-wait net-device-added "INTERFACE=$iface" && |
|
51 |
emitted="$emitted $iface" || |
|
52 |
echo "warn: ${UPSTART_JOB} failed to emit net-device-added INTERFACE=$iface" |
|
53 |
done
|
|
54 |
||
55 |
[ -z "${emitted# }" ] || |
|
56 |
echo "${UPSTART_JOB}: emitted ifup for ${emitted# }" |
|
57 |
end script |