summaryrefslogtreecommitdiff
path: root/share/customize-resolved.sh
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2023-01-11 19:29:46 +0100
committerHelmut Grohne <helmut@subdivi.de>2023-01-11 21:23:55 +0100
commitc751e229a1f8118787954d26bab4c300d114300e (patch)
tree6bff23af27bb52f8fbc2657cc2c07597bf1edf8d /share/customize-resolved.sh
parent0fb18186ca3ed2ac16efeb34ea3840e17aafaa3d (diff)
downloaddebvm-c751e229a1f8118787954d26bab4c300d114300e.tar.gz
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.
Diffstat (limited to 'share/customize-resolved.sh')
-rwxr-xr-xshare/customize-resolved.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/share/customize-resolved.sh b/share/customize-resolved.sh
new file mode 100755
index 0000000..e8fe248
--- /dev/null
+++ b/share/customize-resolved.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright 2022 Helmut Grohne <helmut@subdivi.de>
+# SPDX-License-Identifier: MIT
+#
+# This is a mmdebstrap customize hook that enables systemd-resolved on various
+# Debian releases.
+
+set -eu
+
+TARGET=$1
+
+LIBNSS_RESOLVE_VERSION=$(dpkg-query --root "$TARGET" -f '${Version}' -W libnss-resolve 2>/dev/null) || :
+
+if dpkg --compare-versions "$LIBNSS_RESOLVE_VERSION" lt 251.3-2~exp1; then
+ if test "${MMDEBSTRAP_MODE:-}" = chrootless; then
+ systemctl --root "$TARGET" enable systemd-resolved.service
+ else
+ chroot "$TARGET" systemctl enable systemd-resolved.service
+ fi
+
+ if test -z "$LIBNSS_RESOLVE_VERSION"; then
+ ln -fs ../run/systemd/resolve/resolv.conf "$TARGET/etc/resolv.conf"
+ else
+ ln -fs ../run/systemd/resolve/stub-resolv.conf "$TARGET/etc/resolv.conf"
+ fi
+fi