summaryrefslogtreecommitdiff
path: root/share/customize-networkd.sh
diff options
context:
space:
mode:
authorHelmut Grohne <helmutg@debian.org>2023-01-15 08:54:06 +0000
committerHelmut Grohne <helmutg@debian.org>2023-01-15 08:54:06 +0000
commitb6aee3905cc52fa206cfbef3fe01d2c6388435a1 (patch)
tree86ab25a9c7434d62019359da0f996d2097aa8247 /share/customize-networkd.sh
parent59c77e0c3422287651c6e270917bcfa04a6c17a6 (diff)
parentca2cbf6d84dcc96845fcc6521aebe3b5076cdb32 (diff)
downloaddebvm-b6aee3905cc52fa206cfbef3fe01d2c6388435a1.tar.gz
Merge branch 'helmut' into 'main'
reduce usage of DEBVER See merge request helmutg/debvm!22
Diffstat (limited to 'share/customize-networkd.sh')
-rwxr-xr-xshare/customize-networkd.sh37
1 files changed, 37 insertions, 0 deletions
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"