#!/usr/bin/env bash # SPDX-License-Identifier: LGPL-2.1-or-later # shellcheck disable=SC2016 set -eux set -o pipefail # shellcheck source=test/units/util.sh . "$(dirname "$0")"/util.sh at_exit() { systemctl stop systemd-networkd if [[ -v NETWORK_NAME && -v NETDEV_NAME && -v LINK_NAME ]]; then rm -fvr {/usr/lib,/etc,/run}/systemd/network/"$NETWORK_NAME" "/run/lib/systemd/network/$NETDEV_NAME" \ {/usr/lib,/etc}/systemd/network/"$LINK_NAME" "/etc/systemd/network/${NETWORK_NAME}.d" \ "new" "+4" fi rm -f /run/systemd/networkd.conf.d/10-hoge.conf } trap at_exit EXIT systemctl unmask systemd-networkd.service systemctl start systemd-networkd.service export NETWORK_NAME="10-networkctl-test-$RANDOM.network" export NETDEV_NAME="10-networkctl-test-$RANDOM.netdev" export LINK_NAME="10-networkctl-test-$RANDOM.link" cat >"/usr/lib/systemd/network/$NETWORK_NAME" <new <"+4" <"/usr/lib/systemd/network/$LINK_NAME" </run/systemd/networkd.conf.d/10-hoge.conf <