diff --git a/dist/debian/ifupdown-ng.networking.service b/dist/debian/ifupdown-ng.networking.service new file mode 100644 index 0000000..5aad2f9 --- /dev/null +++ b/dist/debian/ifupdown-ng.networking.service @@ -0,0 +1,15 @@ +[Unit] +Description=ifupdown-ng networking initialization +Documentation=man:interfaces(5) man:ifup(8) man:ifdown(8) + +[Service] +Type=oneshot +RemainAfterExit=yes +SyslogIdentifier=networking +TimeoutStopSec=30s +ExecStart=/usr/share/ifupdown-ng/sbin/networking start +ExecStop=/usr/share/ifupdown-ng/sbin/networking stop +ExecRestart=/usr/share/ifupdown-ng/sbin/networking restart + +[Install] +WantedBy=basic.target network.target multi-user.target network-online.target diff --git a/dist/debian/networking b/dist/debian/networking new file mode 100644 index 0000000..327e08d --- /dev/null +++ b/dist/debian/networking @@ -0,0 +1,68 @@ +#!/bin/sh +# +# Wrapper script for networking set up and teardown via unit file +# +# Thu, 01 Oct 2020 22:47:43 +0200 +# -- Maximilian Wilhelm +# + +STATE_DIR="/run/ifsate" + +# Make sure the state dir is present +if [ ! -d "${STATE_DIR}" ]; then + mkdir "${STATE_DIR}" +fi + +# Check for require binaries +if [ ! -x /sbin/ifup -o ! -x /sbin/ifdown ]; then + echo "ifup and/or ifdown not found!" >&2 + exit 1 +fi + +# Apply defaults if present (verbose mode, kill switch, etc.) +CONFIGURE_INTERFACES=yes + +if [ -f /etc/default/networking ]; then + . /etc/default/networking +fi + +ARGS="" +if [ "${VERBOSE}" = yes ]; then + ARGS="-v" +fi + +# Let's go +case "$1" in + start) + if [ "${CONFIGURE_INTERFACES}" = no ]; then + echo "Not configuring network interfaces, see /etc/default/networking" + exit 0 + fi + + ifup -a ${ARGS} + ;; + + stop) + if [ "${SKIP_DOWN_AT_SYSRESET}" = "yes" ] && systemctl list-jobs | egrep -q '(shutdown|reboot|halt|poweroff)\.target'; then + echo ${NAME}':' "Skipping deconfiguring network interfaces" + exit 0 + fi + + ifdown -a ${ARGS} + ;; + + restart) + ifupdown_init + ifdown -a ${ARGS} + ifup -a ${ARGS} + ;; + + # reload missing here! + + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac + +exit 0 diff --git a/dist/debian/networking.default b/dist/debian/networking.default new file mode 100644 index 0000000..8c6e6f7 --- /dev/null +++ b/dist/debian/networking.default @@ -0,0 +1,13 @@ +# +# Defaults for ifupdown-ng networking service +# + +# Change the below to "yes" if you want ifup/ifdown and it's executors to be +# verbose about what's going on +VERBOSE="no" + +# Set to "yes" if you want to skip deconfiguring all interfaces during system +# reboot and shutdown. This might be of interest in large scale deployments, +# where you might not want to wait for interface deconfiguration to speed up +# shutdown/reboot. +SKIP_DOWN_AT_SYSRESET="yes"