From 987e4e02a9bd62273b67eb07bb5ce670b14ec10f Mon Sep 17 00:00:00 2001 From: Clinton Date: Fri, 1 Jan 2016 14:11:46 +0000 Subject: [PATCH] Fix bug in gravity.sh where IPv6 list was not always populated Failed to be populated if /tmp/piholeIP does not exist. This may happen under the following conditions: - was not generated during install - gravity.sh being run again after the original install (the file is deleted during the installation process) --- gravity.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index c2a0553..091b556 100755 --- a/gravity.sh +++ b/gravity.sh @@ -13,10 +13,6 @@ piholeIPfile=/tmp/piholeIP piholeIPv6file=/etc/pihole/.useIPv6 if [[ -f $piholeIPfile ]];then - 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) }') - fi # 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 @@ -27,6 +23,11 @@ else piholeIP=${piholeIPCIDR%/*} fi +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) }') +fi + # Ad-list sources--one per line in single quotes # The mahakala source is commented out due to many users having issues with it blocking legitimate domains. # Uncomment at your own risk