Compare commits
30 Commits
developmen
...
v2.9-alpha
Author | SHA1 | Date | |
---|---|---|---|
|
84b54065ff | ||
|
f8edc810ff | ||
|
c9b461a2f8 | ||
|
e60490b4ed | ||
|
0ba6e59888 | ||
|
0dd5970f49 | ||
|
f73360e791 | ||
|
0d5600c21d | ||
|
c78c619cfb | ||
|
6469586a67 | ||
|
42614f6a7a | ||
|
aac7fa9c14 | ||
|
4b1633eac4 | ||
|
86d7eada79 | ||
|
a70c3bac61 | ||
|
67834062bc | ||
|
5b0e73c9f3 | ||
|
f671eef3f0 | ||
|
5ab54012d5 | ||
|
a04b7c4e99 | ||
|
e4ce5e3601 | ||
|
06f1aea319 | ||
|
2ab6746d53 | ||
|
253dfdf084 | ||
|
cec727be9d | ||
|
1d9531ef70 | ||
|
fbc400c67e | ||
|
0e59cf0fd1 | ||
|
96bacc372a | ||
|
6daf80ef56 |
32
advanced/Scripts/updatePihole.sh
Normal file
32
advanced/Scripts/updatePihole.sh
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Pi-hole: A black hole for Internet advertisements
|
||||||
|
# (c) 2015, 2016 by Jacob Salmela
|
||||||
|
# Network-wide ad blocking via your Raspberry Pi
|
||||||
|
# http://pi-hole.net
|
||||||
|
# Checks if Pi-hole needs updating and then
|
||||||
|
#
|
||||||
|
# Pi-hole is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# Taken from http://stackoverflow.com/questions/3258243/check-if-pull-needed-in-git
|
||||||
|
|
||||||
|
# Move into the git directory
|
||||||
|
cd /etc/.pihole/
|
||||||
|
|
||||||
|
LOCAL=$(git rev-parse @)
|
||||||
|
REMOTE=$(git rev-parse @{u})
|
||||||
|
BASE=$(git merge-base @ @{u})
|
||||||
|
|
||||||
|
if [[ $LOCAL = $REMOTE ]]; then
|
||||||
|
echo "Up-to-date"
|
||||||
|
elif [[ $LOCAL = $BASE ]]; then
|
||||||
|
echo "Updating Pi-hole..."
|
||||||
|
git pull
|
||||||
|
/opt/pihole/updatePiholeSecondary.sh
|
||||||
|
elif [[ $REMOTE = $BASE ]]; then
|
||||||
|
: # Need to push, so do nothing
|
||||||
|
else
|
||||||
|
: # Diverged, so do nothing
|
||||||
|
fi
|
103
advanced/Scripts/updatePiholeSecondary.sh
Normal file
103
advanced/Scripts/updatePiholeSecondary.sh
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Pi-hole: A black hole for Internet advertisements
|
||||||
|
# (c) 2015, 2016 by Jacob Salmela
|
||||||
|
# Network-wide ad blocking via your Raspberry Pi
|
||||||
|
# http://pi-hole.net
|
||||||
|
# Checks if Pi-hole needs updating and then
|
||||||
|
#
|
||||||
|
# Pi-hole is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# Must be root to use this tool
|
||||||
|
if [[ ! $EUID -eq 0 ]];then
|
||||||
|
#echo "::: You are root."
|
||||||
|
#else
|
||||||
|
#echo "::: Sudo will be used for this tool."
|
||||||
|
# Check if it is actually installed
|
||||||
|
# If it isn't, exit because the pihole cannot be invoked without privileges.
|
||||||
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
|
export SUDO="sudo"
|
||||||
|
else
|
||||||
|
echo "::: Please install sudo or run this as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
function updateDependencies(){
|
||||||
|
#Add any new dependencies to the below array`
|
||||||
|
newDependencies=()
|
||||||
|
echo "::: Installing any new dependencies..."
|
||||||
|
for i in "${newDependencies[@]}"; do
|
||||||
|
echo "checking for $i"
|
||||||
|
if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then
|
||||||
|
echo -n " Not found! Installing...."
|
||||||
|
$SUDO apt-get -y -qq install "$i" > /dev/null & spinner $!
|
||||||
|
echo " done!"
|
||||||
|
else
|
||||||
|
echo " already installed!"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stopServices() {
|
||||||
|
# Stop dnsmasq and lighttpd
|
||||||
|
echo ":::"
|
||||||
|
echo -n "::: Stopping services..."
|
||||||
|
$SUDO service lighttpd stop
|
||||||
|
echo " done."
|
||||||
|
}
|
||||||
|
|
||||||
|
installScripts() {
|
||||||
|
# Install the scripts from /etc/.pihole to their various locations
|
||||||
|
echo ":::"
|
||||||
|
echo -n "::: Updating scripts in /opt/pihole..."
|
||||||
|
|
||||||
|
$SUDO cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /opt/pihole/blacklist.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/updatePihole.sh /opt/pihole/updatePihole.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/updatePiholeSecondary.sh /opt/pihole/updatePiholeSecondary.sh
|
||||||
|
$SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh
|
||||||
|
$SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,updatePihole,updatePiholeSecondary,uninstall,setupLCD, piholeDebug}.sh
|
||||||
|
$SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole
|
||||||
|
$SUDO chmod 755 /usr/local/bin/pihole
|
||||||
|
$SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole
|
||||||
|
. /etc/bash_completion.d/pihole
|
||||||
|
|
||||||
|
#Tidy up /usr/local/bin directory if updating an old installation (can probably be removed at some point)
|
||||||
|
oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard updatePihole updatePiholeSecondary uninstall setupLCD piholeDebug)
|
||||||
|
for i in "${oldFiles[@]}"; do
|
||||||
|
if [ -f "/usr/local/bin/$i.sh" ]; then
|
||||||
|
$SUDO rm /usr/local/bin/"$i".sh
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo " done."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
########################
|
||||||
|
# SCRIPT STARTS HERE! #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
#uncomment the below if adding new dependencies (don't forget to update the install script!)
|
||||||
|
#updateDependencies
|
||||||
|
stopServices
|
||||||
|
installScripts
|
||||||
|
|
||||||
|
#TODO:
|
||||||
|
# - Distribute files`
|
||||||
|
# - Run pihole -g
|
||||||
|
# - add root check, maybe? Do we need to? Probably a good idea.
|
||||||
|
# - update install script to populate a config file with:
|
||||||
|
# -IPv4
|
||||||
|
# -IPv6
|
||||||
|
# -UpstreamDNS servers
|
@@ -9,6 +9,10 @@
|
|||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# Pi-hole: Check if Pi-hole needs to be updated. Check once a week on Monday at 23:58
|
||||||
|
# New releases often come out on Sunday, so checking the next day should be effective.
|
||||||
|
#23 58 * * 1 root /usr/local/bin/updatePihole
|
||||||
|
|
||||||
# Pi-hole: Update the ad sources once a week on Sunday at 01:59
|
# Pi-hole: Update the ad sources once a week on Sunday at 01:59
|
||||||
# Download any updates from the adlists
|
# Download any updates from the adlists
|
||||||
59 1 * * 7 root /usr/local/bin/pihole updateGravity
|
59 1 * * 7 root /usr/local/bin/pihole updateGravity
|
||||||
|
@@ -473,16 +473,18 @@ installScripts() {
|
|||||||
$SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh
|
$SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh
|
||||||
$SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh
|
$SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh
|
||||||
$SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh
|
$SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/updatePihole.sh /opt/pihole/updatePihole.sh
|
||||||
|
$SUDO cp /etc/.pihole/advanced/Scripts/updatePiholeSecondary.sh /opt/pihole/updatePiholeSecondary.sh
|
||||||
$SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh
|
$SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh
|
||||||
$SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh
|
$SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh
|
||||||
$SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh
|
$SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,updatePihole,updatePiholeSecondary,uninstall,setupLCD, piholeDebug}.sh
|
||||||
$SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole
|
$SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole
|
||||||
$SUDO chmod 755 /usr/local/bin/pihole
|
$SUDO chmod 755 /usr/local/bin/pihole
|
||||||
$SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole
|
$SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole
|
||||||
. /etc/bash_completion.d/pihole
|
. /etc/bash_completion.d/pihole
|
||||||
|
|
||||||
#Tidy up /usr/local/bin directory if installing over previous install.
|
#Tidy up /usr/local/bin directory if installing over previous install.
|
||||||
oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard uninstall setupLCD piholeDebug)
|
oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard updatePihole updatePiholeSecondary uninstall setupLCD piholeDebug)
|
||||||
for i in "${oldFiles[@]}"; do
|
for i in "${oldFiles[@]}"; do
|
||||||
if [ -f "/usr/local/bin/$i.sh" ]; then
|
if [ -f "/usr/local/bin/$i.sh" ]; then
|
||||||
$SUDO rm /usr/local/bin/"$i".sh
|
$SUDO rm /usr/local/bin/"$i".sh
|
||||||
|
37
pihole
37
pihole
@@ -57,6 +57,11 @@ function updateGravityFunc {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updatePiholeFunc {
|
||||||
|
$SUDO /opt/pihole/updatePihole.sh
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
function setupLCDFunction {
|
function setupLCDFunction {
|
||||||
$SUDO /opt/pihole/setupLCD.sh
|
$SUDO /opt/pihole/setupLCD.sh
|
||||||
exit 1
|
exit 1
|
||||||
@@ -75,21 +80,22 @@ function uninstallFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function helpFunc {
|
function helpFunc {
|
||||||
echo "::: Control all PiHole specific functions!"
|
echo "::: Control all PiHole specific functions!"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Usage: pihole [options]"
|
echo "::: Usage: pihole [options]"
|
||||||
echo "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage"
|
printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Options:"
|
echo "::: Options:"
|
||||||
echo "::: -w, whitelist Whitelist domains"
|
echo "::: -w, whitelist Whitelist domains"
|
||||||
echo "::: -b, blacklist Blacklist domains"
|
echo "::: -b, blacklist Blacklist domains"
|
||||||
echo "::: -d, debug Start a debugging session if having trouble"
|
echo "::: -d, debug Start a debugging session if having trouble"
|
||||||
echo "::: -f, flush Flush the pihole.log file"
|
echo "::: -f, flush Flush the pihole.log file"
|
||||||
echo "::: -u, updateDashboard Update the web dashboard manually"
|
echo "::: -u, updateDashboard Update the web dashboard manually"
|
||||||
echo "::: -g, updateGravity Update the list of ad-serving domains"
|
echo "::: -up, updatePihole Update the Pi-hole core files manually"
|
||||||
echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it"
|
echo "::: -g, updateGravity Update the list of ad-serving domains"
|
||||||
echo "::: -c, chronometer Calculates stats and displays to an LCD"
|
echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it"
|
||||||
echo "::: -h, help Show this help dialog"
|
echo "::: -c, chronometer Calculates stats and displays to an LCD"
|
||||||
|
echo "::: -h, help Show this help dialog"
|
||||||
echo "::: uninstall Uninstall Pi-Hole from your system!"
|
echo "::: uninstall Uninstall Pi-Hole from your system!"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -105,6 +111,7 @@ case "$1" in
|
|||||||
"-d" | "debug" ) debugFunc;;
|
"-d" | "debug" ) debugFunc;;
|
||||||
"-f" | "flush" ) flushFunc;;
|
"-f" | "flush" ) flushFunc;;
|
||||||
"-u" | "updateDashboard" ) updateDashboardFunc;;
|
"-u" | "updateDashboard" ) updateDashboardFunc;;
|
||||||
|
"-up" | "updatePihole" ) updatePiholeFunc;;
|
||||||
"-g" | "updateGravity" ) updateGravityFunc;;
|
"-g" | "updateGravity" ) updateGravityFunc;;
|
||||||
"-s" | "setupLCD" ) setupLCDFunction;;
|
"-s" | "setupLCD" ) setupLCDFunction;;
|
||||||
"-c" | "chronometer" ) chronometerFunc "$@";;
|
"-c" | "chronometer" ) chronometerFunc "$@";;
|
||||||
|
Reference in New Issue
Block a user