Merge pull request #244 from pi-hole/development

Code update for 2016/01/25.
This commit is contained in:
Dan Schaper 2016-01-25 11:04:09 -08:00
commit 0b077b9601
3 changed files with 40 additions and 21 deletions

View file

@ -293,24 +293,37 @@ stopServices(){
} }
checkForDependencies(){ checkForDependencies(){
echo ":::"
#Check to see if apt-get update has already been run today #Running apt-get update/upgrade with minimal output can cause some issues with
timestamp=$(stat -c %Y /var/cache/apt/) #requiring user input (e.g password for phpmyadmin see #218)
timestampAsDate=$(date -d @$timestamp "+%b %e") #We'll change the logic up here, to check to see if there are any updates availible and
# if so, advise the user to run apt-get update/upgrade at their own discretion
today=$(date "+%b %e") today=$(date "+%b %e")
echo ":::"
echo -n "::: Checking apt-get for upgraded packages...."
updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) & spinner $!
echo " done!"
if [ ! "$today" == "$timestampAsDate" ]; then echo ":::"
#update package lists if [ $updatesToInstall > 0 ]; then
echo -n "::: Updating package list before install...." echo "::: There are $updatesToInstall updates availible for your pi!"
$SUDO apt-get -qq update > /dev/null & spinner $! echo "::: Please consider running 'sudo apt-get update', followed by 'sudo apt-get upgrade'"
echo " done!" echo "::: after pi-hole has finished installing."
echo -n "::: Upgrading installed apt-get packages...." echo ":::"
$SUDO apt-get -y -qq upgrade > /dev/null & spinner $! #add in a prompt to give users the option to quit installation or continue
echo " done!" echo -n "::: Would you like to continue with the pi-hole installation? (Y/n):"
else read answer
echo "::: Apt-get update already run today, any more would be overkill..."
fi
case "$answer" in
[yY][eE][sS]|[yY] ) echo "::: Continuing!";;
* ) echo "::: Quitting install, please run 'curl -L install.pi-hole.net | bash' after updating packages!"
exit 0;;
esac
else
echo "::: Your pi is up to date! Continuing with pi-hole installation..."
fi
echo ":::" echo ":::"
echo "::: Checking dependencies:" echo "::: Checking dependencies:"

View file

@ -55,7 +55,8 @@ sources=('https://adaway.org/hosts.txt'
'http://www.malwaredomainlist.com/hostslist/hosts.txt' 'http://www.malwaredomainlist.com/hostslist/hosts.txt'
'http://pgl.yoyo.org/adservers/serverlist.php?' 'http://pgl.yoyo.org/adservers/serverlist.php?'
'http://someonewhocares.org/hosts/hosts' 'http://someonewhocares.org/hosts/hosts'
'http://winhelp2002.mvps.org/hosts.txt') 'http://winhelp2002.mvps.org/hosts.txt'
'http://mirror1.malwaredomains.com/files/justdomains')
# Variables for various stages of downloading and formatting the list # Variables for various stages of downloading and formatting the list
basename=pihole basename=pihole
@ -256,10 +257,15 @@ function gravity_hostFormat() {
echo "::: Formatting domains into a HOSTS file..." echo "::: Formatting domains into a HOSTS file..."
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols # If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
if [[ -n $piholeIPv6 ]];then if [[ -n $piholeIPv6 ]];then
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' > $piholeDir/$accretionDisc #Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain!
echo -e "$piholeIP Pi-Hole.IsWorking.OK \n$piholeIPv6 Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc
else else
# Otherwise, just create gravity.list as normal using IPv4 # Otherwise, just create gravity.list as normal using IPv4
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' > $piholeDir/$accretionDisc #Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain!
echo -e "$piholeIP Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc
fi fi
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
cp $piholeDir/$accretionDisc $adList cp $piholeDir/$accretionDisc $adList