mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Merge pull request #244 from pi-hole/development
Code update for 2016/01/25.
This commit is contained in:
commit
0b077b9601
3 changed files with 40 additions and 21 deletions
|
@ -293,24 +293,37 @@ stopServices(){
|
||||||
}
|
}
|
||||||
|
|
||||||
checkForDependencies(){
|
checkForDependencies(){
|
||||||
echo ":::"
|
|
||||||
#Check to see if apt-get update has already been run today
|
|
||||||
timestamp=$(stat -c %Y /var/cache/apt/)
|
|
||||||
timestampAsDate=$(date -d @$timestamp "+%b %e")
|
|
||||||
today=$(date "+%b %e")
|
|
||||||
|
|
||||||
if [ ! "$today" == "$timestampAsDate" ]; then
|
#Running apt-get update/upgrade with minimal output can cause some issues with
|
||||||
#update package lists
|
#requiring user input (e.g password for phpmyadmin see #218)
|
||||||
echo -n "::: Updating package list before install...."
|
#We'll change the logic up here, to check to see if there are any updates availible and
|
||||||
$SUDO apt-get -qq update > /dev/null & spinner $!
|
# if so, advise the user to run apt-get update/upgrade at their own discretion
|
||||||
echo " done!"
|
|
||||||
echo -n "::: Upgrading installed apt-get packages...."
|
today=$(date "+%b %e")
|
||||||
$SUDO apt-get -y -qq upgrade > /dev/null & spinner $!
|
echo ":::"
|
||||||
echo " done!"
|
echo -n "::: Checking apt-get for upgraded packages...."
|
||||||
else
|
updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) & spinner $!
|
||||||
echo "::: Apt-get update already run today, any more would be overkill..."
|
echo " done!"
|
||||||
fi
|
|
||||||
|
echo ":::"
|
||||||
|
if [ $updatesToInstall > 0 ]; then
|
||||||
|
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 ":::"
|
||||||
|
#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 ":::"
|
echo ":::"
|
||||||
echo "::: Checking dependencies:"
|
echo "::: Checking dependencies:"
|
||||||
|
|
14
gravity.sh
14
gravity.sh
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue