mirror of
https://github.com/Retropex/umbrel-apps.git
synced 2025-05-12 19:30:42 +02:00
Pi hole pre-install hook to disable systemd-resolved's DNS Stub Listener (#258)
Co-authored-by: Steven Briscoe <me@stevenbriscoe.com>
This commit is contained in:
parent
62ca19eeff
commit
d769a428b9
33
pi-hole/hooks/pre-install
Executable file
33
pi-hole/hooks/pre-install
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
RESOLVED_SERVICE_NAME="systemd-resolved"
|
||||||
|
RESOLVED_CONF_FILE="/etc/systemd/resolved.conf"
|
||||||
|
|
||||||
|
# Check if the 'systemd-resolved' service is running
|
||||||
|
if ! systemctl is-active --quiet service "${RESOLVED_SERVICE_NAME}"; then
|
||||||
|
echo "Service '${RESOLVED_SERVICE_NAME}' is not running"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the DNS Stub Listener is running
|
||||||
|
if cat "${RESOLVED_CONF_FILE}" | grep --quiet "^DNSStubListener=no$"; then
|
||||||
|
echo "DNSStubListener already turned off"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Turning off the DNS Stub Listener"
|
||||||
|
|
||||||
|
# Turn off DNSStubListener within config file
|
||||||
|
sed -r -i.orig 's/#?DNSStubListener=yes/DNSStubListener=no/g' "${RESOLVED_CONF_FILE}"
|
||||||
|
|
||||||
|
# Remove active resolv.conf which would have
|
||||||
|
# localhost (systemd-resolved's DNS listener) as the DNS resolver
|
||||||
|
rm -f /etc/resolv.conf
|
||||||
|
|
||||||
|
# Create a symlink between systemd-resolved's upstream resolv.conf
|
||||||
|
# and the OS's resolv.conf
|
||||||
|
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
|
||||||
|
|
||||||
|
echo "Restart service '${RESOLVED_SERVICE_NAME}'"
|
||||||
|
systemctl restart "${RESOLVED_SERVICE_NAME}"
|
@ -1,4 +1,4 @@
|
|||||||
manifestVersion: 1
|
manifestVersion: 1.1
|
||||||
id: pi-hole
|
id: pi-hole
|
||||||
category: Networking
|
category: Networking
|
||||||
name: Pi-hole
|
name: Pi-hole
|
||||||
|
Loading…
Reference in New Issue
Block a user