Skip to content

Commit

Permalink
Merge pull request #1307 from pi-hole/dev
Browse files Browse the repository at this point in the history
Dev -> Master
  • Loading branch information
PromoFaux authored Jan 25, 2023
2 parents db6f9b8 + bb33b4d commit 843b3ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2
ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME 0

ENV FTLCONF_LOCAL_IPV4 0.0.0.0
ENV VIRTUAL_HOST ""
ENV FTL_CMD no-daemon
ENV DNSMASQ_USER pihole

Expand Down

This file was deleted.

19 changes: 14 additions & 5 deletions src/s6/debian-root/usr/local/bin/bash_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ ensure_basic_configuration() {
if [ ! -f /etc/dnsmasq.d/01-pihole.conf ] ; then
cp /etc/.pihole/advanced/01-pihole.conf /etc/dnsmasq.d/
fi;

# setup_or_skip_gravity
}

validate_env() {
Expand Down Expand Up @@ -364,9 +362,7 @@ setup_web_php_env() {
local config_file
config_file="/etc/lighttpd/conf-available/15-pihole-admin.conf"
# if the environment variable VIRTUAL_HOST is not set, or is empty, then set it to the hostname of the container
if [ -z "${VIRTUAL_HOST}" ] || [ "${VIRTUAL_HOST}" == "" ]; then
VIRTUAL_HOST="${HOSTNAME}"
fi
VIRTUAL_HOST="${VIRTUAL_HOST:-$HOSTNAME}"

for config_var in "VIRTUAL_HOST" "CORS_HOSTS" "PHP_ERROR_LOG" "PIHOLE_DOCKER_TAG" "TZ"; do
local beginning_of_line=" \"${config_var}\" => "
Expand All @@ -381,6 +377,19 @@ setup_web_php_env() {

echo " [i] Added ENV to php:"
grep -E '(VIRTUAL_HOST|CORS_HOSTS|PHP_ERROR_LOG|PIHOLE_DOCKER_TAG|TZ)' "$config_file"

# Create an additional file in the lighttpd config directory to redirect the root to the admin page
# if the host matches either VIRTUAL_HOST (Or HOSTNAME if it is not set) or FTLCONF_LOCAL_IPV4
cat <<END > /etc/lighttpd/conf-enabled/15-pihole-admin-redirect-docker.conf
\$HTTP["url"] == "/" {
\$HTTP["host"] == "${VIRTUAL_HOST}" {
url.redirect = ("" => "/admin/")
}
\$HTTP["host"] == "${FTLCONF_LOCAL_IPV4}" {
url.redirect = ("" => "/admin/")
}
}
END
}

setup_web_port() {
Expand Down

0 comments on commit 843b3ff

Please sign in to comment.