From c751e229a1f8118787954d26bab4c300d114300e Mon Sep 17 00:00:00 2001
From: Helmut Grohne <helmut@subdivi.de>
Date: Wed, 11 Jan 2023 19:29:46 +0100
Subject: debvm-create: move functionality into support files

The benefit of this change is that we don't have to escape that much. As
a consequence, it becomes easier to put more code into the customization
hooks, which have access to installed package versions. Thus we can
reduce the use of DEBVER and thus improve working with snapshot.d.o.
---
 share/customize-networkd.sh | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100755 share/customize-networkd.sh

(limited to 'share/customize-networkd.sh')

diff --git a/share/customize-networkd.sh b/share/customize-networkd.sh
new file mode 100755
index 0000000..c89aae2
--- /dev/null
+++ b/share/customize-networkd.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright 2022 Helmut Grohne <helmut@subdivi.de>
+# SPDX-License-Identifier: MIT
+#
+# This is a mmdebstrap customize hook that enables and configures
+# systemd-networkd on various Debian releases.
+
+set -eu
+
+TARGET=$1
+
+SYSTEMD_VERSION=$(dpkg-query --root "$TARGET" -f '${Version}' -W systemd)
+
+if test "${MMDEBSTRAP_MODE:-}" = chrootless; then
+	systemctl --root "$TARGET" enable systemd-networkd.service
+else
+	chroot "$TARGET" systemctl enable systemd-networkd.service
+fi
+
+{
+	echo '[Match]'
+	echo 'Name=en*'
+	if dpkg --compare-versions "$SYSTEMD_VERSION" lt 220-7~; then
+		echo 'Name=eth*'
+	fi
+
+	echo '[Network]'
+	echo 'DHCP=yes'
+
+	if dpkg --compare-versions "$SYSTEMD_VERSION" lt 249; then
+		# This anchor is included by default since bullseye. Fails DNSSEC
+		# validation when missing.
+		echo 'DNSSECNegativeTrustAnchors=home.arpa'
+	fi
+	echo '[DHCP]'
+	echo 'UseDomains=yes'
+} >"$TARGET/etc/systemd/network/20-wired.network"
-- 
cgit v1.2.3