Skip to content

Commit

Permalink
moved pihole's dnsmasq conf setup into container via script for s6 ov…
Browse files Browse the repository at this point in the history
…erlay
  • Loading branch information
Cielquan committed Nov 17, 2019
1 parent c8703e4 commit 0971352
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
3 changes: 3 additions & 0 deletions docker-compose.yaml
Expand Up @@ -44,10 +44,13 @@ services:
- ServerIP=${HOST_IP}
- DNS1=172.16.1.5#53
- DNS2=no
- DOMAIN=${DOMAIN}
- HOST_IP=${HOST_IP}
volumes:
- ./pihole-docker/resolv.conf:/etc/resolv.conf
- ./pihole-docker/configs/pihole/:/etc/pihole/
- ./pihole-docker/configs/dnsmasq.d/dnsmasq.conf:/etc/dnsmasq.d/02-custom.conf
- ./pihole-docker/01-conf-dnsmasq.sh:/etc/cont-init.d/01-conf-dnsmasq.sh
ports:
- "53:53/tcp"
- "53:53/udp"
Expand Down
24 changes: 24 additions & 0 deletions pihole-docker/01-conf-dnsmasq.sh
@@ -0,0 +1,24 @@
#!/usr/bin/with-contenv bash

# ==============================================================================
# Copyright (c) 2019 Christian Riedel
#
# This file 'custom-init.bash' created 2019-11-17 is part of the project/program 'DoTH-DNS'.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the MIT License as published by
# the Massachusetts Institute of Technology.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MIT License for more details.
#
# You should have received a copy of the MIT License
# along with this program. If not, see <https://opensource.org/licenses/MIT>.
#
# Github: https://github.com/Cielquan/
# ==============================================================================

# Script gets called by s6 overlay which setups pihole inside docker container.
# Appends DoTH-DNS' DOMAIN to dnsmasq's configuration file for wildcard use of domain.
printf "\naddress=/%s/%s" "${DOMAIN}" "${HOST_IP}" >> /etc/dnsmasq.d/02-custom.conf
1 change: 1 addition & 0 deletions pihole-docker/configs/dnsmasq.d/dnsmasq.conf
@@ -0,0 +1 @@
addn-hosts=/etc/pihole/lan.list
18 changes: 0 additions & 18 deletions start_doth_dns.bash
Expand Up @@ -411,24 +411,6 @@ else
fi


# ##########################################################################################
# Check for host IP/DOMAIN mapping in 'pihole-docker/configs/dnsmasq.d/dnsmasq.conf'
printf "\n%bINFO: %b Checking for 'pihole-docker/configs/dnsmasq.d/dnsmasq.conf' file.\n" "${CYAN}" "${BLANK}"
if ! [ -f pihole-docker/configs/dnsmasq.d/dnsmasq.conf ] || [[ "${_FLAG_FRESH}" == 'y' ]] ||
! grep -qw -e "${DOMAIN}" 'pihole-docker/configs/dnsmasq.d/dnsmasq.conf'; then
if printf "addn-hosts=/etc/pihole/lan.list\naddress=/%s/%s" "${DOMAIN}" "${HOST_IP}" \
> pihole-docker/configs/dnsmasq.d/dnsmasq.conf; then
printf "%bSUCCESS:%b Created/Overwrote 'pihole-docker/configs/dnsmasq.d/dnsmasq.conf' file.\n" "${GREEN}" "${BLANK}"
else
printf "%bERROR: %b 'pihole-docker/configs/dnsmasq.d/dnsmasq.conf' file could not be created/overwritten.\n" \
"${RED}" "${BLANK}"
exit_err
fi
else
printf "%bSUCCESS:%b Found 'pihole-docker/configs/dnsmasq.d/dnsmasq.conf' file.\n" "${GREEN}" "${BLANK}"
fi


# ##########################################################################################
# Creating/Overwriting '.env' file
if [ -f .env ]; then
Expand Down

0 comments on commit 0971352

Please sign in to comment.