mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Merge pull request #255 from pi-hole/Bugfix/InstallScriptFix
Force apt-get update if it has not been run today. This will stop dependency errors on a fresh install.
This commit is contained in:
commit
60bf14d4dd
1 changed files with 33 additions and 25 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,7 +63,7 @@ else
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ -f "/etc/dnsmasq.d/01-pihole.conf" ]; then
|
||||
if [ -d "/etc/pihole" ]; then
|
||||
#Likely an existing install
|
||||
upgrade=true
|
||||
else
|
||||
|
@ -256,7 +260,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
|
||||
}
|
||||
|
||||
|
@ -269,7 +275,7 @@ installScripts(){
|
|||
$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/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."
|
||||
}
|
||||
|
||||
|
@ -299,30 +305,34 @@ checkForDependencies(){
|
|||
#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")
|
||||
echo ":::"
|
||||
|
||||
if [ ! "$today" == "$timestampAsDate" ]; then
|
||||
#update package lists
|
||||
echo ":::"
|
||||
echo -n "::: apt-get update has not been run today. Running now..."
|
||||
$SUDO apt-get -qq update & spinner $!
|
||||
echo " done!"
|
||||
fi
|
||||
|
||||
echo ":::"
|
||||
echo -n "::: Checking apt-get for upgraded packages...."
|
||||
updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) & spinner $!
|
||||
updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst)
|
||||
echo " done!"
|
||||
|
||||
|
||||
echo ":::"
|
||||
if [ $updatesToInstall > 0 ]; then
|
||||
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 "::: Please consider running 'sudo apt-get update', followed by 'sudo apt-get upgrade'"
|
||||
echo "::: after pi-hole has finished installing."
|
||||
echo "::: We recommend you run 'sudo apt-get upgrade' after installing Pi-Hole! "
|
||||
echo ":::"
|
||||
#add in a prompt to give users the option to quit installation or continue
|
||||
echo -n "::: Would you like to continue with the pi-hole installation? (Y/n):"
|
||||
read answer
|
||||
|
||||
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 ":::"
|
||||
|
@ -477,6 +487,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
|
||||
|
@ -486,8 +497,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
|
||||
|
||||
|
@ -495,6 +504,5 @@ installPihole | tee $tmpLog
|
|||
$SUDO mv $tmpLog $instalLogLoc
|
||||
|
||||
displayFinalMessage
|
||||
|
||||
$SUDO service dnsmasq start
|
||||
$SUDO service lighttpd start
|
||||
$SUDO service lighttpd start
|
Loading…
Reference in a new issue