mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 23:08:07 +00:00
commit
16e4f79f09
@ -9,53 +9,37 @@
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# If you want dnsmasq to read another file, as well as /etc/hosts, use
|
||||
# this.
|
||||
###############################################################################
|
||||
# FILE AUTOMATICALLY POPULATED BY PI-HOLE INSTALL/UPDATE PROCEDURE. #
|
||||
# ANY CHANGES MADE TO THIS FILE AFTER INSTALL WILL BE LOST ON THE NEXT UPDATE #
|
||||
# #
|
||||
# IF YOU WISH TO CHANGE THE UPSTREAM SERVERS, CHANGE THEM IN: #
|
||||
# /etc/pihole/setupVars.conf #
|
||||
# #
|
||||
# ANY OTHER CHANGES SHOULD BE MADE IN A SEPERATE CONFIG FILE #
|
||||
# OR IN /etc/dnsmasq.conf #
|
||||
###############################################################################
|
||||
|
||||
addn-hosts=/etc/pihole/gravity.list
|
||||
|
||||
# The following two options make you a better netizen, since they
|
||||
# tell dnsmasq to filter out queries which the public DNS cannot
|
||||
# answer, and which load the servers (especially the root servers)
|
||||
# unnecessarily. If you have a dial-on-demand link they also stop
|
||||
# these requests from bringing up the link unnecessarily.
|
||||
|
||||
# Never forward plain names (without a dot or domain part)
|
||||
domain-needed
|
||||
# Never forward addresses in the non-routed address spaces.
|
||||
|
||||
bogus-priv
|
||||
|
||||
# If you don't want dnsmasq to read /etc/resolv.conf or any other
|
||||
# file, getting its servers from this file instead (see below), then
|
||||
# uncomment this.
|
||||
no-resolv
|
||||
|
||||
# Add other name servers here, with domain specs if they are for
|
||||
# non-public domains.
|
||||
server=@DNS1@
|
||||
server=@DNS2@
|
||||
|
||||
# If you want dnsmasq to listen for DHCP and DNS requests only on
|
||||
# specified interfaces (and the loopback) give the name of the
|
||||
# interface (eg eth0) here.
|
||||
interface=@INT@
|
||||
# Or which to listen on by address (remember to include 127.0.0.1 if
|
||||
# you use this.)
|
||||
|
||||
listen-address=127.0.0.1
|
||||
|
||||
# Set the cachesize here.
|
||||
cache-size=10000
|
||||
|
||||
# For debugging purposes, log each DNS query as it passes through
|
||||
# dnsmasq.
|
||||
log-queries
|
||||
log-facility=/var/log/pihole.log
|
||||
|
||||
# Normally responses which come from /etc/hosts and the DHCP lease
|
||||
# file have Time-To-Live set as zero, which conventionally means
|
||||
# do not cache further. If you are happy to trade lower load on the
|
||||
# server for potentially stale date, you can set a time-to-live (in
|
||||
# seconds) here.
|
||||
local-ttl=300
|
||||
|
||||
# This allows it to continue functioning without being blocked by syslog, and allows syslog to use dnsmasq for DNS queries without risking deadlock
|
||||
log-async
|
||||
|
145
advanced/Scripts/update.sh
Normal file
145
advanced/Scripts/update.sh
Normal file
@ -0,0 +1,145 @@
|
||||
#!/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
|
||||
# Whitelists domains
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Variables
|
||||
|
||||
webInterfaceGitUrl="https://github.com/pi-hole/AdminLTE.git"
|
||||
webInterfaceDir="/var/www/html/admin"
|
||||
piholeGitUrl="https://github.com/pi-hole/pi-hole.git"
|
||||
piholeFilesDir="/etc/.pihole"
|
||||
|
||||
spinner()
|
||||
{
|
||||
local pid=$1
|
||||
local delay=0.50
|
||||
local spinstr='/-\|'
|
||||
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
|
||||
local temp=${spinstr#?}
|
||||
printf " [%c] " "$spinstr"
|
||||
local spinstr=${temp}${spinstr%"$temp"}
|
||||
sleep ${delay}
|
||||
printf "\b\b\b\b\b\b"
|
||||
done
|
||||
printf " \b\b\b\b"
|
||||
}
|
||||
|
||||
getGitFiles() {
|
||||
# Setup git repos for directory and repository passed
|
||||
# as arguments 1 and 2
|
||||
echo ":::"
|
||||
echo "::: Checking for existing repository..."
|
||||
if is_repo "${1}"; then
|
||||
update_repo "${1}"
|
||||
else
|
||||
make_repo "${1}" "${2}"
|
||||
fi
|
||||
}
|
||||
|
||||
is_repo() {
|
||||
# Use git to check if directory is currently under VCS
|
||||
echo -n "::: Checking $1 is a repo..."
|
||||
cd "${1}" &> /dev/null || return 1
|
||||
git status &> /dev/null && echo " OK!"; return 0 || echo " not found!"; return 1
|
||||
}
|
||||
|
||||
make_repo() {
|
||||
# Remove the non-repod interface and clone the interface
|
||||
echo -n "::: Cloning $2 into $1..."
|
||||
rm -rf "${1}"
|
||||
git clone -q --depth 1 "${2}" "${1}" > /dev/null & spinner $!
|
||||
echo " done!"
|
||||
}
|
||||
|
||||
update_repo() {
|
||||
# Pull the latest commits
|
||||
echo -n "::: Updating repo in $1..."
|
||||
cd "${1}" || exit 1
|
||||
git stash -q > /dev/null & spinner $!
|
||||
git pull -q > /dev/null & spinner $!
|
||||
echo " done!"
|
||||
}
|
||||
|
||||
if [ ! -d "/etc/.pihole" ]; then #This is unlikely
|
||||
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
||||
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||
exit 1;
|
||||
fi
|
||||
if [ ! -d "/var/www/html/admin" ]; then #This is unlikely
|
||||
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
||||
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "::: Checking for updates..."
|
||||
piholeVersion=$(pihole -v -p -c)
|
||||
piholeVersionLatest=$(pihole -v -p -l)
|
||||
|
||||
webVersion=$(pihole -v -a -c)
|
||||
webVersionLatest=$(pihole -v -a -l)
|
||||
|
||||
echo ":::"
|
||||
echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)"
|
||||
echo "::: Web Admin version is $webVersion (Latest version is $webVersionLatest)"
|
||||
echo ":::"
|
||||
|
||||
# Logic
|
||||
# If latest versions are blank - we've probably hit Github rate limit (stop running `pihole -up so often!):
|
||||
# Update anyway
|
||||
# If Core up to date AND web up to date:
|
||||
# Do nothing
|
||||
# If Core up to date AND web NOT up to date:
|
||||
# Pull web repo
|
||||
# If Core NOT up to date AND web up to date:
|
||||
# pull pihole repo, run install --unattended -- reconfigure
|
||||
# if Core NOT up to date AND web NOT up to date:
|
||||
# pull pihole repo run install --unattended
|
||||
|
||||
|
||||
|
||||
if [[ ${piholeVersion} == ${piholeVersionLatest} && ${webVersion} == ${webVersionLatest} ]]; then
|
||||
echo "::: Everything is up to date!"
|
||||
echo ""
|
||||
exit 0
|
||||
|
||||
elif [[ ${piholeVersion} == ${piholeVersionLatest} && ${webVersion} != ${webVersionLatest} ]]; then
|
||||
echo "::: Pi-hole Web Admin files out of date"
|
||||
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl}
|
||||
echo ":::"
|
||||
webVersion=$(pihole -v -a -c)
|
||||
echo "::: Web Admin version is now at ${webVersion}"
|
||||
echo "::: If you had made any changes in '/var/www/html/admin', they have been stashed using 'git stash'"
|
||||
echo ""
|
||||
|
||||
elif [[ ${piholeVersion} != ${piholeVersionLatest} && ${webVersion} == ${webVersionLatest} ]]; then
|
||||
echo "::: Pi-hole core files out of date"
|
||||
getGitFiles ${piholeFilesDir} ${piholeGitUrl}
|
||||
/etc/.pihole/automated\ install/basic-install.sh --reconfigure --unattended
|
||||
echo ":::"
|
||||
piholeVersion=$(pihole -v -p -c)
|
||||
echo "::: Pi-hole version is now at ${piholeVersion}"
|
||||
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
||||
echo ""
|
||||
|
||||
elif [[ ${piholeVersion} != ${piholeVersionLatest} && ${webVersion} != ${webVersionLatest} ]]; then
|
||||
echo "::: Updating Everything"
|
||||
getGitFiles ${piholeFilesDir} ${piholeGitUrl}
|
||||
/etc/.pihole/automated\ install/basic-install.sh --unattended
|
||||
webVersion=$(pihole -v -a -c)
|
||||
piholeVersion=$(pihole -v -p -c)
|
||||
echo ":::"
|
||||
echo "::: Pi-hole version is now at ${piholeVersion}"
|
||||
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
||||
echo ":::"
|
||||
echo "::: Pi-hole version is now at ${piholeVersion}"
|
||||
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
||||
echo ""
|
||||
fi
|
@ -3,18 +3,100 @@
|
||||
# (c) 2015, 2016 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# Whitelists domains
|
||||
# shows version numbers
|
||||
#
|
||||
# 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.
|
||||
|
||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
||||
# Flags:
|
||||
latest=false
|
||||
current=false
|
||||
|
||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||
normalOutput(){
|
||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
||||
|
||||
echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)"
|
||||
echo "::: Web-Admin version is $webVersion (Latest version is $webVersionLatest)"
|
||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||
|
||||
echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)"
|
||||
echo "::: Web-Admin version is $webVersion (Latest version is $webVersionLatest)"
|
||||
}
|
||||
|
||||
webOutput(){
|
||||
for var in "$@"
|
||||
do
|
||||
case "$var" in
|
||||
"-l" | "--latest" ) latest=true;;
|
||||
"-c" | "--current" ) current=true;;
|
||||
* ) echo "::: Invalid Option!"; exit 1;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${latest}" == true && "${current}" == false ]]; then
|
||||
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||
echo ${webVersionLatest}
|
||||
elif [[ "${latest}" == false && "${current}" == true ]]; then
|
||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
||||
echo ${webVersion}
|
||||
else
|
||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
||||
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||
echo "::: Web-Admin version is $webVersion (Latest version is $webVersionLatest)"
|
||||
fi
|
||||
}
|
||||
|
||||
coreOutput(){
|
||||
for var in "$@"
|
||||
do
|
||||
case "$var" in
|
||||
"-l" | "--latest" ) latest=true;;
|
||||
"-c" | "--current" ) current=true;;
|
||||
* ) echo "::: Invalid Option!"; exit 1;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${latest}" == true && "${current}" == false ]]; then
|
||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||
echo ${piholeVersionLatest}
|
||||
elif [[ "${latest}" == false && "${current}" == true ]]; then
|
||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||
echo ${piholeVersion}
|
||||
else
|
||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||
echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)"
|
||||
fi
|
||||
}
|
||||
|
||||
helpFunc()
|
||||
{
|
||||
echo ":::"
|
||||
echo "::: Show Pi-hole/Web Admin versions"
|
||||
echo ":::"
|
||||
echo "::: Usage: pihole -v [ -a | -p ] [ -l | -c ]"
|
||||
echo ":::"
|
||||
echo "::: Options:"
|
||||
echo "::: -a, --admin Show both current and latest versions of web admin"
|
||||
echo "::: -p, --pihole Show both current and latest versions of Pi-hole core files"
|
||||
echo "::: -l, --latest (Only after -a | -p) Return only latest version"
|
||||
echo "::: -c, --current (Only after -a | -p) Return only current version"
|
||||
echo "::: -h, --help Show this help dialog"
|
||||
echo ":::"
|
||||
exit 0
|
||||
}
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
normalOutput
|
||||
fi
|
||||
|
||||
for var in "$@"
|
||||
do
|
||||
case "$var" in
|
||||
"-a" | "--admin" ) shift; webOutput "$@";;
|
||||
"-p" | "--pihole" ) shift; coreOutput "$@" ;;
|
||||
"-h" | "--help" ) helpFunc;;
|
||||
esac
|
||||
done
|
@ -702,6 +702,7 @@ update_repo() {
|
||||
# Pull the latest commits
|
||||
echo -n "::: Updating repo in $1..."
|
||||
cd "${1}" || exit 1
|
||||
git stash -q > /dev/null & spinner $!
|
||||
git pull -q > /dev/null & spinner $!
|
||||
echo " done!"
|
||||
}
|
||||
|
71
pihole
71
pihole
@ -13,7 +13,6 @@
|
||||
# Must be root to use this tool
|
||||
if [[ ! $EUID -eq 0 ]];then
|
||||
if [ -x "$(command -v sudo)" ];then
|
||||
echo "::: Elevating to root with sudo"
|
||||
exec sudo bash "$0" "$@"
|
||||
exit $?
|
||||
else
|
||||
@ -46,70 +45,7 @@ flushFunc() {
|
||||
|
||||
|
||||
updatePiholeFunc() {
|
||||
|
||||
if [ ! -d "/etc/.pihole" ]; then #This is unlikely
|
||||
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
||||
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||
exit 1;
|
||||
fi
|
||||
if [ ! -d "/var/www/html/admin" ]; then #This is unlikely
|
||||
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
||||
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "::: Checking for updates..."
|
||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||
|
||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
||||
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||
|
||||
echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)"
|
||||
echo "::: Web Admin version is $webVersion (Latest version is $webVersionLatest)"
|
||||
echo ":::"
|
||||
|
||||
if [[ ${piholeVersion} == ${piholeVersionLatest} ]] ; then
|
||||
echo "::: Pi-hole Base files are already up to date! Version: ${piholeVersionLatest}"
|
||||
echo "::: No need to update!"
|
||||
echo ":::"
|
||||
|
||||
if [[ ${webVersion} == ${webVersionLatest} ]] ; then
|
||||
echo "::: Web Admin files are already up to date!"
|
||||
echo "::: No need to update!"
|
||||
echo ":::"
|
||||
else
|
||||
echo "::: An Update is available for the Web Admin!"
|
||||
echo ":::"
|
||||
echo "::: Fetching latest changes from GitHub..."
|
||||
cd /var/www/html/admin
|
||||
git pull origin master
|
||||
echo ":::"
|
||||
echo "::: Pi-hole Web Admin has been updated to ${webVersion}"
|
||||
echo "::: See https://changes.pi-hole.net for details"
|
||||
fi
|
||||
else
|
||||
echo -n "::: An update is available for "
|
||||
if [[ ${webVersion} == ${webVersionLatest} ]] ; then
|
||||
echo " Pi-Hole!"
|
||||
else
|
||||
echo " Pi-Hole base files and the Web Admin. Both will be updated!"
|
||||
fi
|
||||
|
||||
echo "::: Fetching latest changes from GitHub..."
|
||||
cd /etc/.pihole
|
||||
git pull origin master
|
||||
/etc/.pihole/automated\ install/basic-install.sh --unattended
|
||||
|
||||
echo ":::"
|
||||
echo "::: Pi-hole has been updated to version ${piholeVersionLatest}"
|
||||
if [[ ${webVersion} != ${webVersionLatest} ]] ; then
|
||||
echo "::: Web Admin has been updated to version ${webVersionLatest}"
|
||||
fi
|
||||
echo ":::"
|
||||
echo "::: See https://changes.pi-hole.net for details"
|
||||
fi
|
||||
|
||||
/opt/pihole/update.sh
|
||||
exit 0
|
||||
}
|
||||
|
||||
@ -155,7 +91,8 @@ uninstallFunc() {
|
||||
}
|
||||
|
||||
versionFunc() {
|
||||
/opt/pihole/version.sh
|
||||
shift
|
||||
/opt/pihole/version.sh "$@"
|
||||
exit 0
|
||||
}
|
||||
|
||||
@ -197,7 +134,7 @@ case "$1" in
|
||||
"-s" | "setupLCD" ) setupLCDFunction;;
|
||||
"-c" | "chronometer" ) chronometerFunc "$@";;
|
||||
"-h" | "help" ) helpFunc;;
|
||||
"-v" | "version" ) versionFunc;;
|
||||
"-v" | "version" ) versionFunc "$@";;
|
||||
"-q" | "query" ) queryFunc "$@";;
|
||||
"uninstall" ) uninstallFunc;;
|
||||
* ) helpFunc;;
|
||||
|
Loading…
Reference in New Issue
Block a user