From 72becc3c170d24adc22290c8b11198ce78755124 Mon Sep 17 00:00:00 2001 From: ryt51V Date: Mon, 29 Feb 2016 22:26:11 +0000 Subject: [PATCH] Output IP and interface used in all circumstances. --- advanced/Scripts/blacklist.sh | 9 +++++++-- advanced/Scripts/whitelist.sh | 9 +++++++-- gravity.sh | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index d3ca9840..a4fbe22e 100644 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -38,14 +38,16 @@ piholeINTfile=/etc/pihole/piholeINT piholeIPfile=/etc/pihole/piholeIP piholeIPv6file=/etc/pihole/.useIPv6 +echo ":::" + # Know which interface we are using. if [[ -f $piholeINTfile ]]; then # This file should normally exist - it was saved as part of the install. IPv4dev=$(cat $piholeINTfile) else # If it doesn't, we err on the side of working with the majority of setups and detect the most likely interface. + echo "::: Warning: ${piholeINTfile} is missing. Auto detecting interface." IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') - echo "::: Warning: ${piholeINTfile} is missing. Using interface ${IPv4dev}." fi # Know which IPv4 address we are using. @@ -55,11 +57,14 @@ if [[ -f $piholeIPfile ]];then else # If it doesn't, we err on the side of working with the majority of setups and detect the most likely IPv4 address, # which is the first one we find belonging to the given interface. + echo "::: Warning: ${piholeIPfile} is missing. Auto detecting IP address." piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | head -n 1) piholeIP=${piholeIPCIDR%/*} - echo "::: Warning: ${piholeIPfile} is missing. Using IPv4 address ${piholeIP}." fi +echo "::: Large gravitational pull detected at ${piholeIP} (${IPv4dev})." +echo ":::" + modifyHost=false diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index b1833486..576f0479 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -37,14 +37,16 @@ piholeINTfile=/etc/pihole/piholeINT piholeIPfile=/etc/pihole/piholeIP piholeIPv6file=/etc/pihole/.useIPv6 +echo ":::" + # Know which interface we are using. if [[ -f $piholeINTfile ]]; then # This file should normally exist - it was saved as part of the install. IPv4dev=$(cat $piholeINTfile) else # If it doesn't, we err on the side of working with the majority of setups and detect the most likely interface. + echo "::: Warning: ${piholeINTfile} is missing. Auto detecting interface." IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') - echo "::: Warning: ${piholeINTfile} is missing. Using interface ${IPv4dev}." fi # Know which IPv4 address we are using. @@ -54,11 +56,14 @@ if [[ -f $piholeIPfile ]];then else # If it doesn't, we err on the side of working with the majority of setups and detect the most likely IPv4 address, # which is the first one we find belonging to the given interface. + echo "::: Warning: ${piholeIPfile} is missing. Auto detecting IP address." piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | head -n 1) piholeIP=${piholeIPCIDR%/*} - echo "::: Warning: ${piholeIPfile} is missing. Using IPv4 address ${piholeIP}." fi +echo "::: Large gravitational pull detected at ${piholeIP} (${IPv4dev})." +echo ":::" + modifyHost=false diff --git a/gravity.sh b/gravity.sh index 1b193a55..cff6fa48 100755 --- a/gravity.sh +++ b/gravity.sh @@ -35,14 +35,16 @@ adListDefault=/etc/pihole/adlists.default whitelistScript=/usr/local/bin/whitelist.sh blacklistScript=/usr/local/bin/blacklist.sh +echo ":::" + # Know which interface we are using. if [[ -f $piholeINTfile ]]; then # This file should normally exist - it was saved as part of the install. IPv4dev=$(cat $piholeINTfile) else # If it doesn't, we err on the side of working with the majority of setups and detect the most likely interface. + echo "::: Warning: ${piholeINTfile} is missing. Auto detecting interface." IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') - echo "::: Warning: ${piholeINTfile} is missing. Using interface ${IPv4dev}." fi # Know which IPv4 address we are using. @@ -52,11 +54,14 @@ if [[ -f $piholeIPfile ]];then else # If it doesn't, we err on the side of working with the majority of setups and detect the most likely IPv4 address, # which is the first one we find belonging to the given interface. + echo "::: Warning: ${piholeIPfile} is missing. Auto detecting IP address." piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | head -n 1) piholeIP=${piholeIPCIDR%/*} - echo "::: Warning: ${piholeIPfile} is missing. Using IPv4 address ${piholeIP}." fi +echo "::: Large gravitational pull detected at ${piholeIP} (${IPv4dev})." +echo ":::" + if [[ -f $piholeIPv6file ]];then # If the file exists, then the user previously chose to use IPv6 in the automated installer piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')