Output IP and interface used in all circumstances.

This commit is contained in:
ryt51V 2016-02-29 22:26:11 +00:00
parent d823af896a
commit 72becc3c17
3 changed files with 21 additions and 6 deletions

View file

@ -38,14 +38,16 @@ piholeINTfile=/etc/pihole/piholeINT
piholeIPfile=/etc/pihole/piholeIP piholeIPfile=/etc/pihole/piholeIP
piholeIPv6file=/etc/pihole/.useIPv6 piholeIPv6file=/etc/pihole/.useIPv6
echo ":::"
# Know which interface we are using. # Know which interface we are using.
if [[ -f $piholeINTfile ]]; then if [[ -f $piholeINTfile ]]; then
# This file should normally exist - it was saved as part of the install. # This file should normally exist - it was saved as part of the install.
IPv4dev=$(cat $piholeINTfile) IPv4dev=$(cat $piholeINTfile)
else else
# If it doesn't, we err on the side of working with the majority of setups and detect the most likely interface. # 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)}') 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 fi
# Know which IPv4 address we are using. # Know which IPv4 address we are using.
@ -55,11 +57,14 @@ if [[ -f $piholeIPfile ]];then
else else
# If it doesn't, we err on the side of working with the majority of setups and detect the most likely IPv4 address, # 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. # 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) piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | head -n 1)
piholeIP=${piholeIPCIDR%/*} piholeIP=${piholeIPCIDR%/*}
echo "::: Warning: ${piholeIPfile} is missing. Using IPv4 address ${piholeIP}."
fi fi
echo "::: Large gravitational pull detected at ${piholeIP} (${IPv4dev})."
echo ":::"
modifyHost=false modifyHost=false

View file

@ -37,14 +37,16 @@ piholeINTfile=/etc/pihole/piholeINT
piholeIPfile=/etc/pihole/piholeIP piholeIPfile=/etc/pihole/piholeIP
piholeIPv6file=/etc/pihole/.useIPv6 piholeIPv6file=/etc/pihole/.useIPv6
echo ":::"
# Know which interface we are using. # Know which interface we are using.
if [[ -f $piholeINTfile ]]; then if [[ -f $piholeINTfile ]]; then
# This file should normally exist - it was saved as part of the install. # This file should normally exist - it was saved as part of the install.
IPv4dev=$(cat $piholeINTfile) IPv4dev=$(cat $piholeINTfile)
else else
# If it doesn't, we err on the side of working with the majority of setups and detect the most likely interface. # 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)}') 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 fi
# Know which IPv4 address we are using. # Know which IPv4 address we are using.
@ -54,11 +56,14 @@ if [[ -f $piholeIPfile ]];then
else else
# If it doesn't, we err on the side of working with the majority of setups and detect the most likely IPv4 address, # 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. # 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) piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | head -n 1)
piholeIP=${piholeIPCIDR%/*} piholeIP=${piholeIPCIDR%/*}
echo "::: Warning: ${piholeIPfile} is missing. Using IPv4 address ${piholeIP}."
fi fi
echo "::: Large gravitational pull detected at ${piholeIP} (${IPv4dev})."
echo ":::"
modifyHost=false modifyHost=false

View file

@ -35,14 +35,16 @@ adListDefault=/etc/pihole/adlists.default
whitelistScript=/usr/local/bin/whitelist.sh whitelistScript=/usr/local/bin/whitelist.sh
blacklistScript=/usr/local/bin/blacklist.sh blacklistScript=/usr/local/bin/blacklist.sh
echo ":::"
# Know which interface we are using. # Know which interface we are using.
if [[ -f $piholeINTfile ]]; then if [[ -f $piholeINTfile ]]; then
# This file should normally exist - it was saved as part of the install. # This file should normally exist - it was saved as part of the install.
IPv4dev=$(cat $piholeINTfile) IPv4dev=$(cat $piholeINTfile)
else else
# If it doesn't, we err on the side of working with the majority of setups and detect the most likely interface. # 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)}') 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 fi
# Know which IPv4 address we are using. # Know which IPv4 address we are using.
@ -52,11 +54,14 @@ if [[ -f $piholeIPfile ]];then
else else
# If it doesn't, we err on the side of working with the majority of setups and detect the most likely IPv4 address, # 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. # 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) piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | head -n 1)
piholeIP=${piholeIPCIDR%/*} piholeIP=${piholeIPCIDR%/*}
echo "::: Warning: ${piholeIPfile} is missing. Using IPv4 address ${piholeIP}."
fi fi
echo "::: Large gravitational pull detected at ${piholeIP} (${IPv4dev})."
echo ":::"
if [[ -f $piholeIPv6file ]];then if [[ -f $piholeIPv6file ]];then
# If the file exists, then the user previously chose to use IPv6 in the automated installer # 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) }') piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')