Skip to content

Commit

Permalink
overhaul of custom s6 scripts for pihole
Browse files Browse the repository at this point in the history
  • Loading branch information
Cielquan committed Feb 15, 2020
1 parent d51b67c commit d2d90c7
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/with-contenv bash

# ==============================================================================
# Copyright (c) 2019 Christian Riedel
# ======================================================================================
# Copyright (c) 2019-2020 Christian Riedel
#
# This file 'custom-init.bash' created 2019-11-17 is part of the project/program 'DoTH-DNS'.
# This file '01-conf-dnsmasq.sh' 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 GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand All @@ -18,8 +19,47 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# 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
# Creates dnsmasq config file adding `lan.list` file and wildcard DNS entry for
# DOMAIN on HOST_IP

YEAR=$(date +"%Y")
ISODATE=$(date +"%Y-%m-%d")

cat << EOF > /etc/dnsmasq.d/02-doth.conf
# ======================================================================================
# Copyright (c) 2019-${YEAR} Christian Riedel
#
# This file '02-doth.conf' created ${ISODATE}
# 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 GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 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
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Github: https://github.com/Cielquan/
# ======================================================================================
########################################################################################
# THIS FILE IS AUTOMATICALLY POPULATED BY A SCRIPT ON CONTAINER BOOT #
# ANY CHANGES MADE TO THIS FILE AFTER BOOT WILL BE LOST ON THE NEXT REBOOT #
# #
# #
# ANY CHANGES SHOULD BE MADE IN A SEPARATE CONFIG FILE: #
# ~/DoTH-DNS/pihole-docker/configs/dnsmasq.d/<filename.conf> #
########################################################################################
addn-hosts=/etc/pihole/lan.list
address=/${DOMAIN}/${HOST_IP}
EOF
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/with-contenv bash

# ======================================================================================
# Copyright (c) 2019-2020 Christian Riedel
#
# This file '02-conf-dns.sh' created 2020-02-13
# 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 GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 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
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Github: https://github.com/Cielquan/
# ======================================================================================

# Changes pihole upstream DNS to unbound after setup.
# Done by script so no IP address needs to be fixed beforehand for more dynamic setup.

UNBOUND_IP="$(dig @127.0.0.11 unbound | sed 's/127.0.0.11//g' |
grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | awk '{print $5}')"

sed -i "s/PIHOLE_DNS_1=.*/PIHOLE_DNS_1=${UNBOUND_IP}#53/" /etc/pihole/setupVars.conf

0 comments on commit d2d90c7

Please sign in to comment.