mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Merge remote-tracking branch 'refs/remotes/pi-hole/master' into CBH---Descrition-for-pi-hole-v1-back-function
# Conflicts: # automated install/basic-install.sh
This commit is contained in:
commit
088bd632ab
3 changed files with 52 additions and 28 deletions
|
@ -16,7 +16,9 @@
|
|||
#
|
||||
# curl -L install.pi-hole.net | bash
|
||||
|
||||
|
||||
######## VARIABLES #########
|
||||
|
||||
tmpLog=/tmp/pihole-install.log
|
||||
instalLogLoc=/etc/pihole/install.log
|
||||
|
||||
|
@ -34,7 +36,9 @@ columns=$(tput cols)
|
|||
r=$(( rows / 2 ))
|
||||
c=$(( columns / 2 ))
|
||||
|
||||
|
||||
# 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)}')
|
||||
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}')
|
||||
|
@ -59,8 +63,8 @@ else
|
|||
fi
|
||||
fi
|
||||
|
||||
# Is this if statement used anymore?
|
||||
if [ -f "/etc/dnsmasq.d/01-pihole.conf" ]; then
|
||||
|
||||
if [ -d "/etc/pihole" ]; then
|
||||
# Likely an existing install
|
||||
upgrade=true
|
||||
else
|
||||
|
@ -182,7 +186,7 @@ useIPv6dialog() {
|
|||
# Show the IPv6 address used for blocking
|
||||
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
|
||||
$SUDO mkdir -p /etc/pihole/
|
||||
|
||||
$SUDO touch /etc/pihole/.useIPv6
|
||||
}
|
||||
|
||||
|
@ -257,7 +261,9 @@ setStaticIPv4() {
|
|||
else
|
||||
setDHCPCD
|
||||
$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
|
||||
}
|
||||
|
||||
|
@ -297,24 +303,37 @@ stopServices() {
|
|||
}
|
||||
|
||||
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
|
||||
# it needs to have been run at least once on new installs!
|
||||
|
||||
timestamp=$(stat -c %Y /var/cache/apt/)
|
||||
timestampAsDate=$(date -d @$timestamp "+%b %e")
|
||||
today=$(date "+%b %e")
|
||||
|
||||
if [ ! "$today" == "$timestampAsDate" ]; then
|
||||
#update package lists
|
||||
echo -n "::: Updating package list before install...."
|
||||
$SUDO apt-get -qq update > /dev/null & spinner $!
|
||||
echo ":::"
|
||||
echo -n "::: apt-get update has not been run today. Running now..."
|
||||
$SUDO apt-get -qq update & spinner $!
|
||||
echo " done!"
|
||||
echo -n "::: Upgrading installed apt-get packages...."
|
||||
$SUDO apt-get -y -qq upgrade > /dev/null & spinner $!
|
||||
echo " done!"
|
||||
else
|
||||
echo "::: Apt-get update already run today, any more would be overkill..."
|
||||
fi
|
||||
|
||||
echo ":::"
|
||||
echo -n "::: Checking apt-get for upgraded packages...."
|
||||
updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst)
|
||||
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 "::: Checking dependencies:"
|
||||
|
||||
|
@ -436,7 +455,7 @@ installPihole() {
|
|||
# Install base files and web interface
|
||||
checkForDependencies # done
|
||||
stopServices
|
||||
|
||||
$SUDO mkdir -p /etc/pihole/
|
||||
$SUDO chown www-data:www-data /var/www/html
|
||||
$SUDO chmod 775 /var/www/html
|
||||
$SUDO usermod -a -G www-data pi
|
||||
|
@ -466,6 +485,7 @@ The install log is in /etc/pihole." $r $c
|
|||
|
||||
######## SCRIPT ############
|
||||
# Start the installer
|
||||
$SUDO mkdir -p /etc/pihole/
|
||||
welcomeDialogs
|
||||
|
||||
# Just back up the original Pi-hole right away since it won't take long and it gets it out of the way
|
||||
|
@ -475,8 +495,6 @@ chooseInterface
|
|||
# Let the user decide if they want to block ads over IPv4 and/or IPv6
|
||||
use4andor6
|
||||
|
||||
|
||||
|
||||
# Install and log everything to a file
|
||||
installPihole | tee $tmpLog
|
||||
|
||||
|
|
12
gravity.sh
12
gravity.sh
|
@ -55,7 +55,8 @@ sources=('https://adaway.org/hosts.txt'
|
|||
'http://www.malwaredomainlist.com/hostslist/hosts.txt'
|
||||
'http://pgl.yoyo.org/adservers/serverlist.php?'
|
||||
'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
|
||||
basename=pihole
|
||||
|
@ -256,10 +257,15 @@ function gravity_hostFormat() {
|
|||
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 [[ -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
|
||||
# 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
|
||||
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
||||
cp $piholeDir/$accretionDisc $adList
|
||||
|
|
Loading…
Reference in a new issue