Skip to content

Commit

Permalink
Update Pi-hole to v6 development branch
Browse files Browse the repository at this point in the history
DO NOT MERGE

Signed-off-by: Kyle Harding <[email protected]>
  • Loading branch information
klutchell committed Dec 6, 2023
1 parent a15b668 commit 36a4832
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 75 deletions.
2 changes: 1 addition & 1 deletion balena.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Pi-hole"
type: "sw.application"
version: 2023.11.0
version: 6.0.0
description: "Pi-hole is a Linux network-level advertisement and Internet tracker blocking application!"
post-provisioning: >-
## Usage instructions
Expand Down
3 changes: 0 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ services:
- NET_ADMIN
volumes:
- "pihole_config:/etc/pihole"
- "dnsmasq_config:/etc/dnsmasq.d"
dns:
- "127.0.0.1"
- "1.1.1.1"
Expand All @@ -28,8 +27,6 @@ services:
environment:
DNSMASQ_LISTENING: all
PIHOLE_DNS_: 1.1.1.1;1.0.0.1
FONTFACE: Terminus
FONTSIZE: 8x14
WEBPASSWORD: balena
VIRTUAL_HOST: balena-devices.com
WEB_BIND_ADDR: 0.0.0.0
Expand Down
17 changes: 8 additions & 9 deletions pihole/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# https://hub.docker.com/r/pihole/pihole/tags
FROM pihole/pihole:2023.11.0@sha256:24b1ef8f66d810faffefdb9b66850bbe2d55013506b892605acef414e210edeb
FROM pihole/pihole:development-v6

ENV DEBIAN_FRONTEND noninteractive
# https://wiki.alpinelinux.org/wiki/Fonts
# hadolint ignore=DL3018
RUN apk add --no-cache dbus font-terminus kbd

# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install --no-install-recommends -y console-setup dbus netcat && \
apt-get clean && rm -rf /var/lib/apt/lists/*
COPY balena-init.sh /

COPY cont-init.d/ /etc/cont-init.d/
COPY s6-overlay/ /etc/s6-overlay/
RUN chmod +x /balena-init.sh

RUN chmod +x /etc/cont-init.d/10-custom.sh
ENTRYPOINT [ "tini", "--", "/balena-init.sh" ]

ENV DBUS_SYSTEM_BUS_ADDRESS 'unix:path=/host/run/dbus/system_bus_socket'
ENV CONSOLE_FONT 'ter-u16n'
81 changes: 81 additions & 0 deletions pihole/balena-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env bash

set -e

# avoid port conflicts with resin-dns
# https://docs.pi-hole.net/ftldns/interfaces/
mkdir -p /etc/dnsmasq.d
echo "bind-interfaces" >/etc/dnsmasq.d/90-resin-dns.conf
echo "except-interface=resin-dns" >>/etc/dnsmasq.d/90-resin-dns.conf
# remove deprecated dnsmasq config files if they exist
rm -f /etc/dnsmasq.d/balena.conf /etc/dnsmasq.d/01-pihole.conf

# source bash functions like setFTLConfigValue
# shellcheck source=/dev/null
# . /usr/bin/bash_functions.sh

# enable inclusion of dnsmasq.d conf files
# https://github.com/pi-hole/FTL/pull/1734
pihole-FTL --config misc.etc_dnsmasq_d true

# update the webpassword if one was provided
pihole setpassword "${WEBPASSWORD:-}" || true

# check if we are using unbound as upstream DNS
if [[ ${PIHOLE_DNS_%;*} =~ ^127\.0\.0\.1#5053$ ]]; then
# https://docs.pi-hole.net/guides/dns/unbound/
# https://docs.pi-hole.net/ftldns/dnsmasq_warn/#reducing-dns-packet-size-for-nameserver-address-to-safe_pktsz
pkt_size=1232
echo "Reducing DNS packet size for nameserver ${PIHOLE_DNS_%;*} to ${pkt_size}..."
echo "edns-packet-max=${pkt_size}" >/etc/dnsmasq.d/99-edns.conf
fi

# execute the Pi-hole entrypoint in the background
/usr/bin/start.sh &
pid=$!

# quit the plymouth (balena logo) service so that we can see the TTY
echo "Stopping plymouth service..."
dbus-send \
--system \
--dest=org.freedesktop.systemd1 \
--type=method_call \
--print-reply \
/org/freedesktop/systemd1 org.freedesktop.systemd1.Manager.StartUnit \
string:"plymouth-quit.service" string:"replace"

# get the FTL webserver port
webserver_port="$(pihole-FTL --config webserver.port)"
webserver_port="${webserver_port%%,*}"

is_api_available() {
response="$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:${webserver_port}/api/auth")"
case "${response}" in
200 | 401) return 0 ;;
*) return 1 ;;
esac
}

set -x

# wait for FTL API to be available
while ! is_api_available; do
sleep 2
done

console=/dev/tty1

# check if console is available
if [ -e "${console}" ]; then
# https://wiki.alpinelinux.org/wiki/Fonts
# https://www.man7.org/linux/man-pages/man8/setfont.8.html
echo "Setting console font to ${CONSOLE_FONT}..."
setfont -C "${console}" /usr/share/consolefonts/"${CONSOLE_FONT}".psf.gz

# start PADD as a background process
echo "Starting PADD..."
/usr/local/bin/padd --secret "${WEBPASSWORD:-}" 2>/dev/null >"${console}" &
fi

# reattach to the Pi-hole entrypoint process
wait $pid
28 changes: 0 additions & 28 deletions pihole/cont-init.d/10-custom.sh

This file was deleted.

Empty file.
Empty file.
5 changes: 0 additions & 5 deletions pihole/s6-overlay/s6-rc.d/padd/finish

This file was deleted.

28 changes: 0 additions & 28 deletions pihole/s6-overlay/s6-rc.d/padd/run

This file was deleted.

1 change: 0 additions & 1 deletion pihole/s6-overlay/s6-rc.d/padd/type

This file was deleted.

Empty file.

0 comments on commit 36a4832

Please sign in to comment.