-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kyle Harding <[email protected]>
- Loading branch information
Showing
11 changed files
with
96 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:2024.06.0@sha256:5c56e9b2fb9715382ebf49f5487aede1ccd933a0807cab2d6dea9136c084c7e0 | ||
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/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 | ||
|
||
# Use EDNS_PACKET_MAX=1232 to avoid unbound DNS packet size warnings | ||
# 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 | ||
if [[ ${EDNS_PACKET_MAX:-} =~ [0-9]+$ ]]; then | ||
echo "Reducing DNS packet size to ${EDNS_PACKET_MAX}..." | ||
echo "edns-packet-max=${EDNS_PACKET_MAX}" >/etc/dnsmasq.d/99-edns.conf | ||
fi | ||
|
||
# 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 | ||
|
||
# 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 | ||
} | ||
|
||
# wait for FTL API to be available | ||
# shellcheck disable=SC2310 | ||
while ! is_api_available; do | ||
sleep 2 | ||
done | ||
|
||
console=/dev/tty1 | ||
|
||
# check if console is available | ||
if [[ -e "${console}" ]] && [[ -n "${CONSOLE_FONT}" ]]; 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 | ||
|
||
# calculate the size of the target tty rather than the current terminal session | ||
stty_size="$(stty size -F "${console}")" | ||
console_height="$(echo "${stty_size}" | awk '{print $1}')" | ||
console_width="$(echo "${stty_size}" | awk '{print $2}')" | ||
|
||
sed "s|console_height=.*|console_height=${console_height}|" -i /usr/local/bin/padd | ||
sed "s|console_width=.*|console_width=${console_width}|" -i /usr/local/bin/padd | ||
|
||
# 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}" |
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.