From b79ff05e29a7a007a6d607ccdd0f679a9706a5a3 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 27 Jul 2018 15:21:25 -0700 Subject: [PATCH 1/5] Move template files to own subdir. Include pihole-FTL.conf in templates. Signed-off-by: Dan Schaper --- advanced/{ => Templates}/logrotate | 0 advanced/Templates/pihole-FTL.conf | 78 +++++++++++++++++++++ advanced/{ => Templates}/pihole-FTL.service | 0 advanced/{ => Templates}/pihole.cron | 0 advanced/{ => Templates}/pihole.sudo | 0 automated install/basic-install.sh | 13 ++-- 6 files changed, 87 insertions(+), 4 deletions(-) rename advanced/{ => Templates}/logrotate (100%) create mode 100644 advanced/Templates/pihole-FTL.conf rename advanced/{ => Templates}/pihole-FTL.service (100%) rename advanced/{ => Templates}/pihole.cron (100%) rename advanced/{ => Templates}/pihole.sudo (100%) diff --git a/advanced/logrotate b/advanced/Templates/logrotate similarity index 100% rename from advanced/logrotate rename to advanced/Templates/logrotate diff --git a/advanced/Templates/pihole-FTL.conf b/advanced/Templates/pihole-FTL.conf new file mode 100644 index 00000000..f855cf19 --- /dev/null +++ b/advanced/Templates/pihole-FTL.conf @@ -0,0 +1,78 @@ +## Listen only for local socket connections or permit all connections +## Options: localonly, all + +#SOCKET_LISTENING=localonly + +## Display all queries? Set to no to hide query display +## Options: yes, no + +#QUERY_DISPLAY=yes + +## Allow FTL to analyze AAAA queries from pihole.log? +## Options: yes, no + +#AAAA_QUERY_ANALYSIS=yes + +## Should FTL try to resolve IPv6 addresses to host names? +## Options: yes, no + +#RESOLVE_IPV6=yes + +## Should FTL try to resolve IPv4 addresses to host names? +## Options: yes, no + +#RESOLVE_IPV4=yes + +## How long should queries be stored in the database [days]? +## Setting this to 0 disables the database +## See: https://docs.pi-hole.net/ftldns/database/ +## Options: number of days + +#MAXDBDAYS=365 + +## How often do we store queries in FTL's database [minutes]? +## See: https://docs.pi-hole.net/ftldns/database/ +## Options: number of minutes + +#DBINTERVAL=1.0 + +## Specify path and filename of FTL's SQLite3 long-term database. +## Setting this to DBFILE= disables the database altogether +## See: https://docs.pi-hole.net/ftldns/database/ +## Option: path to db file + +#DBFILE=/etc/pihole/pihole-FTL.db + +## Up to how many hours of queries should be imported from the database and logs [hours]? +## Maximum is 744 (31 days) +## Options: number of days + +#MAXLOGAGE=24.0 + +## On which port should FTL be listening? +## Options: tcp port + +#FTLPORT=4711 + +## Which privacy level is used? +## See: https://docs.pi-hole.net/ftldns/privacylevels/ +## Options: 0, 1, 2, 3 + +#PRIVACYLEVEL=0 + +## Should FTL ignore queries coming from the local machine? +## Options: yes, no + +#IGNORE_LOCALHOST=no + +## How should FTL reply to blocked queries? +## See: https://docs.pi-hole.net/ftldns/blockingmode/ +## Options: NULL, IP-AAAA-NODATA, IP, NXDOMAIN + +#BLOCKINGMODE=NULL + +## Controls if FTLDNS should print extended details about regex matching into pihole-FTL.log. +## See: https://docs.pi-hole.net/ftldns/regex/overview/ +## Options: true, false + +#REGEX_DEBUGMODE=false diff --git a/advanced/pihole-FTL.service b/advanced/Templates/pihole-FTL.service similarity index 100% rename from advanced/pihole-FTL.service rename to advanced/Templates/pihole-FTL.service diff --git a/advanced/pihole.cron b/advanced/Templates/pihole.cron similarity index 100% rename from advanced/pihole.cron rename to advanced/Templates/pihole.cron diff --git a/advanced/pihole.sudo b/advanced/Templates/pihole.sudo similarity index 100% rename from advanced/pihole.sudo rename to advanced/Templates/pihole.sudo diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 79e8e1ae..45954693 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1553,7 +1553,7 @@ installPiholeWeb() { # Make the .d directory if it doesn't exist mkdir -p /etc/sudoers.d/ # and copy in the pihole sudoers file - cp ${PI_HOLE_LOCAL_REPO}/advanced/pihole.sudo /etc/sudoers.d/pihole + cp ${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole.sudo /etc/sudoers.d/pihole # Add lighttpd user (OS dependent) to sudoers file echo "${LIGHTTPD_USER} ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole @@ -1575,7 +1575,7 @@ installCron() { echo "" echo -ne " ${INFO} ${str}..." # Copy the cron file over from the local repo - cp ${PI_HOLE_LOCAL_REPO}/advanced/pihole.cron /etc/cron.d/pihole + cp ${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole.cron /etc/cron.d/pihole # Randomize gravity update time sed -i "s/59 1 /$((1 + RANDOM % 58)) $((3 + RANDOM % 2))/" /etc/cron.d/pihole # Randomize update checker time @@ -1699,7 +1699,7 @@ installLogrotate() { echo "" echo -ne " ${INFO} ${str}..." # Copy the file over from the local repo - cp ${PI_HOLE_LOCAL_REPO}/advanced/logrotate /etc/pihole/logrotate + cp ${PI_HOLE_LOCAL_REPO}/advanced/Templates/logrotate /etc/pihole/logrotate # Different operating systems have different user / group # settings for logrotate that makes it impossible to create # a static logrotate file that will work with e.g. @@ -2023,7 +2023,12 @@ FTLinstall() { pushd "$(mktemp -d)" > /dev/null || { echo "Unable to make temporary directory for FTL binary download"; return 1; } # Always replace pihole-FTL.service - install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/pihole-FTL.service" "/etc/init.d/pihole-FTL" + install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.service" "/etc/init.d/pihole-FTL" + + # Install template if it does not exist + if [[ ! -f /etc/pihole/pihole-FTL.conf ]]; then + install -o "${USER}" -Dm644 -t "${PI_HOLE_INSTALL_DIR}/advanced/Templates/pihole-FTL.conf" "/etc/pihole/pihole-FTL.conf" + fi local ftlBranch local url From ad20d5ac1c696a9a54a22ccd0c1992f30e4043ac Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 27 Jul 2018 15:39:37 -0700 Subject: [PATCH 2/5] Remove -t SOURCE and DIRECTORY reversal flag on install. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 45954693..85703e4d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2026,8 +2026,8 @@ FTLinstall() { install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.service" "/etc/init.d/pihole-FTL" # Install template if it does not exist - if [[ ! -f /etc/pihole/pihole-FTL.conf ]]; then - install -o "${USER}" -Dm644 -t "${PI_HOLE_INSTALL_DIR}/advanced/Templates/pihole-FTL.conf" "/etc/pihole/pihole-FTL.conf" + if [[ ! -f "/etc/pihole/pihole-FTL.conf" ]]; then + install -o "${USER}" -Dm644 "${PI_HOLE_INSTALL_DIR}/advanced/Templates/pihole-FTL.conf" "/etc/pihole/pihole-FTL.conf" fi local ftlBranch From 512d2dd5f8dda7070c5d0db0b3bf30549f56422a Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 27 Jul 2018 15:47:20 -0700 Subject: [PATCH 3/5] Source git repo and not /opt location. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 85703e4d..d4955de8 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2027,7 +2027,7 @@ FTLinstall() { # Install template if it does not exist if [[ ! -f "/etc/pihole/pihole-FTL.conf" ]]; then - install -o "${USER}" -Dm644 "${PI_HOLE_INSTALL_DIR}/advanced/Templates/pihole-FTL.conf" "/etc/pihole/pihole-FTL.conf" + install -o "${USER}" -Dm644 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.conf" "/etc/pihole/pihole-FTL.conf" fi local ftlBranch From f2c675cff64a99bd66f913fbeff4bec5d816a21d Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 28 Jul 2018 16:16:16 -0700 Subject: [PATCH 4/5] Formatted pihole-FTL.conf for readability. Signed-off-by: Dan Schaper --- advanced/Templates/pihole-FTL.conf | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/advanced/Templates/pihole-FTL.conf b/advanced/Templates/pihole-FTL.conf index f855cf19..a884f242 100644 --- a/advanced/Templates/pihole-FTL.conf +++ b/advanced/Templates/pihole-FTL.conf @@ -1,78 +1,78 @@ +## Socket Listening ## Listen only for local socket connections or permit all connections ## Options: localonly, all - #SOCKET_LISTENING=localonly +## Query Display ## Display all queries? Set to no to hide query display ## Options: yes, no - #QUERY_DISPLAY=yes +## AAA Query Analysis ## Allow FTL to analyze AAAA queries from pihole.log? ## Options: yes, no - #AAAA_QUERY_ANALYSIS=yes +## Resolve IPv6 ## Should FTL try to resolve IPv6 addresses to host names? ## Options: yes, no - #RESOLVE_IPV6=yes +## Resolve IPv4 ## Should FTL try to resolve IPv4 addresses to host names? ## Options: yes, no - #RESOLVE_IPV4=yes +## Max Database Days ## How long should queries be stored in the database [days]? ## Setting this to 0 disables the database ## See: https://docs.pi-hole.net/ftldns/database/ ## Options: number of days - #MAXDBDAYS=365 +## Database Interval ## How often do we store queries in FTL's database [minutes]? ## See: https://docs.pi-hole.net/ftldns/database/ ## Options: number of minutes - #DBINTERVAL=1.0 +## Database File ## Specify path and filename of FTL's SQLite3 long-term database. ## Setting this to DBFILE= disables the database altogether ## See: https://docs.pi-hole.net/ftldns/database/ ## Option: path to db file - #DBFILE=/etc/pihole/pihole-FTL.db +## Max Log Age ## Up to how many hours of queries should be imported from the database and logs [hours]? ## Maximum is 744 (31 days) ## Options: number of days - #MAXLOGAGE=24.0 +## FTL Port ## On which port should FTL be listening? ## Options: tcp port - #FTLPORT=4711 +## Privacy Level ## Which privacy level is used? ## See: https://docs.pi-hole.net/ftldns/privacylevels/ ## Options: 0, 1, 2, 3 - #PRIVACYLEVEL=0 +## Ignore Localhost ## Should FTL ignore queries coming from the local machine? ## Options: yes, no - #IGNORE_LOCALHOST=no +## Blocking Mode ## How should FTL reply to blocked queries? ## See: https://docs.pi-hole.net/ftldns/blockingmode/ ## Options: NULL, IP-AAAA-NODATA, IP, NXDOMAIN - #BLOCKINGMODE=NULL +## Regex Debug Mode ## Controls if FTLDNS should print extended details about regex matching into pihole-FTL.log. ## See: https://docs.pi-hole.net/ftldns/regex/overview/ ## Options: true, false - #REGEX_DEBUGMODE=false From 94b7c8eb597a7d6c8ed1fb0c27a5b6bc8755691d Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 28 Jul 2018 19:58:23 -0700 Subject: [PATCH 5/5] Added header for file. Not using standard Pi-hole copyright header. Signed-off-by: Dan Schaper --- advanced/Templates/pihole-FTL.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/advanced/Templates/pihole-FTL.conf b/advanced/Templates/pihole-FTL.conf index a884f242..e4b9fae9 100644 --- a/advanced/Templates/pihole-FTL.conf +++ b/advanced/Templates/pihole-FTL.conf @@ -1,3 +1,9 @@ +### This file contains parameters for FTL behavior. +### At install, all parameters are commented out. The user can select desired options. +### Options shown are the default configuration. No modification is needed for most +### installations. +### Visit https://docs.pi-hole.net/ftldns/configfile/ for more detailed parameter explanations + ## Socket Listening ## Listen only for local socket connections or permit all connections ## Options: localonly, all