#!/bin/sh
# ifupdown like networking.service with /etc/default/networking.
# start: the auto interfaces, after a stop also the hotplug ones.
# stop: all interfaces except lo.
set -a
# shellcheck disable=SC1091
[ -r /etc/default/networking ] && . /etc/default/networking
set +a
mkdir -p /run/network
case $1 in
start)
	ifup -a --read-environment
	rc=$?
	if [ -f /run/network/restart-hotplug ]; then
		ifup -a --read-environment --allow=hotplug || :
	fi
	exit $rc
	;;
stop)
	ifdown -a --read-environment --exclude=lo
	rc=$?
	touch /run/network/restart-hotplug
	exit $rc
	;;
*)
	echo "usage: networking start|stop" >&2
	exit 100
	;;
esac
