blob: 1c5d0d190692875ffbbec9750b339a695aa50bbe [file] [log] [blame]
# network-interface - configure network device
#
# This service causes network devices to be brought up or down as a result
# of hardware being added or removed, including that which isn't ordinarily
# removable.
# Taken from Ubuntu 14.04
description "configure network device"
emits net-device-up
emits net-device-down
emits static-network-up
start on net-device-added
stop on net-device-removed INTERFACE=$INTERFACE
instance $INTERFACE
export INTERFACE
pre-start script
if [ "$INTERFACE" = lo ]; then
# bring this up even if /etc/network/interfaces is broken
ifconfig lo 127.0.0.1 up || true
initctl emit -n net-device-up \
IFACE=lo LOGICAL=lo ADDRFAM=inet METHOD=loopback || true
fi
mkdir -p /run/network
if ifquery --allow hotplug -l | grep -q "^${INTERFACE}\$"; then
exec ifup --allow hotplug $INTERFACE
else
exec ifup --allow auto $INTERFACE
fi
end script
post-stop script
if ifquery --allow hotplug -l | grep -q "^${INTERFACE}\$"; then
exec ifdown --force --allow hotplug $INTERFACE
else
exec ifdown --force --allow auto $INTERFACE
fi
end script