From 08e6f60941f3a6486e038421b5d887c324664728 Mon Sep 17 00:00:00 2001 From: Jim Liu Date: Fri, 22 Apr 2016 01:42:43 +0800 Subject: [PATCH] Update blacklist.sh --- advanced/Scripts/blacklist.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index f7a18eae..e28188eb 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -42,12 +42,19 @@ verbose=true domList=() domToRemoveList=() +piholeIPfile=/etc/pihole/piholeIP piholeIPv6file=/etc/pihole/.useIPv6 -# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script -IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') -piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') -piholeIP=${piholeIPCIDR%/*} +if [[ -f $piholeIPfile ]];then + # If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script + piholeIP=$(cat $piholeIPfile) + #rm $piholeIPfile +else + # Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script + IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') + piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') + piholeIP=${piholeIPCIDR%/*} +fi modifyHost=false