From 5d696b63a9cba3309f08f2106cc62143a21e4a31 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 12 Oct 2023 14:55:10 +0200 Subject: [PATCH] Add hook around systemd-resolved installation Once systemd-resolved is installed, it replaces /etc/resolv.conf with a symlink to /run, where resolved is supposed to place resulting configuration. However, it is not possible to startup a service inside chroot environment. So, we workaround that by preserving resolv.conf content in destination file for resolved before it is installed. --- install-systemd-resolved/cleanup.d/30-cleanup-resolved-mimic | 4 ++++ .../pre-install.d/05-preserve-nameservers | 5 +++++ 2 files changed, 9 insertions(+) create mode 100755 install-systemd-resolved/cleanup.d/30-cleanup-resolved-mimic create mode 100755 install-systemd-resolved/pre-install.d/05-preserve-nameservers diff --git a/install-systemd-resolved/cleanup.d/30-cleanup-resolved-mimic b/install-systemd-resolved/cleanup.d/30-cleanup-resolved-mimic new file mode 100755 index 0000000..5fb365b --- /dev/null +++ b/install-systemd-resolved/cleanup.d/30-cleanup-resolved-mimic @@ -0,0 +1,4 @@ +#!/bin/bash + +rm ${TARGET_ROOT}/run/systemd/resolve/stub-resolv.conf +rmdir ${TARGET_ROOT}/run/systemd/resolve/ diff --git a/install-systemd-resolved/pre-install.d/05-preserve-nameservers b/install-systemd-resolved/pre-install.d/05-preserve-nameservers new file mode 100755 index 0000000..3d1e724 --- /dev/null +++ b/install-systemd-resolved/pre-install.d/05-preserve-nameservers @@ -0,0 +1,5 @@ +#!/bin/bash + +mkdir -p /run/systemd/resolve +echo "Saving /etc/resolve.conf to mimic systemd-resolved until in chroot" +cat /etc/resolv.conf > /run/systemd/resolve/stub-resolv.conf