Merge remote-tracking branch 'refs/remotes/pi-hole/master' into CBH---Upsteam-DNS-enhancement-v2

# Conflicts:
#	automated install/basic-install.sh
This commit is contained in:
Chad Howell 2016-01-27 22:34:32 -05:00
commit 00b28836f4
3 changed files with 50 additions and 21 deletions

View file

@ -16,7 +16,9 @@
# #
# curl -L install.pi-hole.net | bash # curl -L install.pi-hole.net | bash
######## VARIABLES ######### ######## VARIABLES #########
tmpLog=/tmp/pihole-install.log tmpLog=/tmp/pihole-install.log
instalLogLoc=/etc/pihole/install.log instalLogLoc=/etc/pihole/install.log
@ -34,7 +36,9 @@ columns=$(tput cols)
r=$(( rows / 2 )) r=$(( rows / 2 ))
c=$(( columns / 2 )) c=$(( columns / 2 ))
# Find IP used to route to outside world # Find IP used to route to outside world
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)}')
IPv4addr=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}') IPv4addr=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}') IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}')
@ -59,7 +63,7 @@ else
fi fi
fi fi
if [ -f "/etc/dnsmasq.d/01-pihole.conf" ]; then if [ -d "/etc/pihole" ]; then
#Likely an existing install #Likely an existing install
upgrade=true upgrade=true
else else
@ -182,7 +186,7 @@ use4andor6(){
useIPv6dialog(){ useIPv6dialog(){
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) }')
whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$piholeIPv6 will be used to block ads." $r $c whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$piholeIPv6 will be used to block ads." $r $c
$SUDO mkdir -p /etc/pihole/
$SUDO touch /etc/pihole/.useIPv6 $SUDO touch /etc/pihole/.useIPv6
} }
@ -256,7 +260,9 @@ setStaticIPv4(){
else else
setDHCPCD setDHCPCD
$SUDO ip addr replace dev $piholeInterface $IPv4addr $SUDO ip addr replace dev $piholeInterface $IPv4addr
echo "Setting IP to $IPv4addr. You may need to restart after the install is complete." echo ":::"
echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete."
echo ":::"
fi fi
} }
@ -314,7 +320,7 @@ installScripts(){
$SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /usr/local/bin/blacklist.sh $SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /usr/local/bin/blacklist.sh
$SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /usr/local/bin/piholeLogFlush.sh $SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /usr/local/bin/piholeLogFlush.sh
$SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /usr/local/bin/updateDashboard.sh $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /usr/local/bin/updateDashboard.sh
$SUDO chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard}.sh $SUDO chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard}.sh
$SUDO echo " done." $SUDO echo " done."
} }
@ -336,24 +342,41 @@ stopServices(){
} }
checkForDependencies(){ checkForDependencies(){
echo ":::"
#Running apt-get update/upgrade with minimal output can cause some issues with
#requiring user input (e.g password for phpmyadmin see #218)
#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
#Check to see if apt-get update has already been run today #Check to see if apt-get update has already been run today
# it needs to have been run at least once on new installs!
timestamp=$(stat -c %Y /var/cache/apt/) timestamp=$(stat -c %Y /var/cache/apt/)
timestampAsDate=$(date -d @$timestamp "+%b %e") timestampAsDate=$(date -d @$timestamp "+%b %e")
today=$(date "+%b %e") today=$(date "+%b %e")
if [ ! "$today" == "$timestampAsDate" ]; then if [ ! "$today" == "$timestampAsDate" ]; then
#update package lists #update package lists
echo -n "::: Updating package list before install...." echo ":::"
$SUDO apt-get -qq update > /dev/null & spinner $! echo -n "::: apt-get update has not been run today. Running now..."
$SUDO apt-get -qq update & spinner $!
echo " done!" echo " done!"
echo -n "::: Upgrading installed apt-get packages...." fi
$SUDO apt-get -y -qq upgrade > /dev/null & spinner $!
echo " done!" echo ":::"
else echo -n "::: Checking apt-get for upgraded packages...."
echo "::: Apt-get update already run today, any more would be overkill..." updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst)
fi echo " done!"
echo ":::"
if [[ $updatesToInstall -eq "0" ]]; then
echo "::: Your pi is up to date! Continuing with pi-hole installation..."
else
echo "::: There are $updatesToInstall updates availible for your pi!"
echo "::: We recommend you run 'sudo apt-get upgrade' after installing Pi-Hole! "
echo ":::"
fi
echo ":::" echo ":::"
echo "::: Checking dependencies:" echo "::: Checking dependencies:"
@ -478,7 +501,7 @@ runGravity(){
installPihole(){ installPihole(){
checkForDependencies # done checkForDependencies # done
stopServices stopServices
$SUDO mkdir -p /etc/pihole/
$SUDO chown www-data:www-data /var/www/html $SUDO chown www-data:www-data /var/www/html
$SUDO chmod 775 /var/www/html $SUDO chmod 775 /var/www/html
$SUDO usermod -a -G www-data pi $SUDO usermod -a -G www-data pi
@ -507,6 +530,7 @@ The install log is in /etc/pihole." $r $c
######## SCRIPT ############ ######## SCRIPT ############
# Start the installer # Start the installer
$SUDO mkdir -p /etc/pihole/
welcomeDialogs welcomeDialogs
# Just back up the original Pi-hole right away since it won't take long and it gets it out of the way # Just back up the original Pi-hole right away since it won't take long and it gets it out of the way
@ -526,6 +550,5 @@ installPihole | tee $tmpLog
$SUDO mv $tmpLog $instalLogLoc $SUDO mv $tmpLog $instalLogLoc
displayFinalMessage displayFinalMessage
$SUDO service dnsmasq start $SUDO service dnsmasq start
$SUDO service lighttpd start $SUDO service lighttpd start

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