2
# the purpose of this job is
3
# * to block running of cloud-init until all network interfaces
4
# configured in /etc/network/interfaces are up
5
# * timeout if they all do not come up in a reasonable amount of time
6
start on mounted MOUNTPOINT=/ and stopped cloud-init-local
7
stop on static-network-up
13
set +e # you cannot trap TERM reliably with 'set -e'
17
local emitted="/run/network/static-network-up-emitted"
18
# /run/network/static-network-up-emitted is written by
19
# upstart (via /etc/network/if-up.d/upstart). its presense would
20
# indicate that static-network-up has already fired.
21
[ -e "$emitted" -o -e "/var/$emitted" ]
24
local uptime="" idle=""
25
if [ -r /proc/uptime ]; then
26
read uptime idle < /proc/uptime
28
echo "$UPSTART_JOB${uptime:+[${uptime}]}:" "$1"
32
# if we received sigterm and static networking is up then it probably
33
# came from upstart as a result of 'stop on static-network-up'
34
if [ -n "$SLEEP_CHILD" ]; then
35
if ! kill $SLEEP_CHILD 2>/dev/null; then
36
[ ! -d "/proc/$SLEEP_CHILD" ] ||
37
msg "hm.. failed to kill sleep pid $SLEEP_CHILD"
40
if static_network_up; then
41
msg "static networking is now up"
44
msg "recieved SIGTERM, networking not up"
49
[ $# -eq 2 ] || msg "waiting $1 seconds for network device"
56
trap handle_sigterm TERM
58
# static_network_up already occurred
59
static_network_up && exit 0
64
msg "gave up waiting for a network device."
65
: > /var/lib/cloud/data/no-net