mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-27 01:30:18 +00:00
Merge branch 'development' into promoTweaksTheSecond
# Conflicts: # advanced/Scripts/blacklist.sh # advanced/Scripts/whitelist.sh
This commit is contained in:
commit
9ab6df0e54
10 changed files with 117 additions and 116 deletions
|
@ -10,18 +10,19 @@
|
|||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
helpFunc()
|
||||
{
|
||||
echo "::: Immediately blacklists one or more domains in the hosts file"
|
||||
echo ":::"
|
||||
echo ":::"
|
||||
echo "::: Usage: pihole -b domain1 [domain2 ...]"
|
||||
echo "::: Options:"
|
||||
echo "::: -d, --delmode Remove domains from the blacklist"
|
||||
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
||||
echo "::: -q, --quiet output is less verbose"
|
||||
echo "::: -h, --help Show this help dialog"
|
||||
echo "::: -l, --list Display your blacklisted domains"
|
||||
helpFunc() {
|
||||
cat << EOM
|
||||
::: Immediately blacklists one or more domains in the hosts file
|
||||
:::
|
||||
:::
|
||||
::: Usage: pihole -b domain1 [domain2 ...]
|
||||
::: Options:
|
||||
::: -d, --delmode Remove domains from the blacklist
|
||||
::: -nr, --noreload Update blacklist without refreshing dnsmasq
|
||||
::: -q, --quiet output is less verbose
|
||||
::: -h, --help Show this help dialog
|
||||
::: -l, --list Display your blacklisted domains
|
||||
EOM
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -51,7 +52,7 @@ HandleOther(){
|
|||
fi
|
||||
}
|
||||
|
||||
PopBlacklistFile(){
|
||||
PopBlacklistFile() {
|
||||
#check blacklist file exists, and if not, create it
|
||||
if [[ ! -f ${blacklist} ]];then
|
||||
touch ${blacklist}
|
||||
|
@ -65,7 +66,7 @@ PopBlacklistFile(){
|
|||
done
|
||||
}
|
||||
|
||||
AddDomain(){
|
||||
AddDomain() {
|
||||
#| sed 's/\./\\./g'
|
||||
bool=false
|
||||
grep -Ex -q "$1" ${blacklist} || bool=true
|
||||
|
@ -83,7 +84,7 @@ AddDomain(){
|
|||
fi
|
||||
}
|
||||
|
||||
RemoveDomain(){
|
||||
RemoveDomain() {
|
||||
|
||||
bool=false
|
||||
grep -Ex -q "$1" ${blacklist} || bool=true
|
||||
|
|
|
@ -17,7 +17,7 @@ gravity="/etc/pihole/gravity.list"
|
|||
|
||||
today=$(date "+%b %e")
|
||||
|
||||
CalcBlockedDomains(){
|
||||
CalcBlockedDomains() {
|
||||
CheckIPv6
|
||||
if [ -e "$gravity" ]; then
|
||||
#Are we IPV6 or IPV4?
|
||||
|
@ -33,7 +33,7 @@ CalcBlockedDomains(){
|
|||
fi
|
||||
}
|
||||
|
||||
CalcQueriesToday(){
|
||||
CalcQueriesToday() {
|
||||
if [ -e "$piLog" ];then
|
||||
queriesToday=$(cat "$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l)
|
||||
else
|
||||
|
@ -41,7 +41,7 @@ CalcQueriesToday(){
|
|||
fi
|
||||
}
|
||||
|
||||
CalcblockedToday(){
|
||||
CalcblockedToday() {
|
||||
if [ -e "$piLog" ] && [ -e "$gravity" ];then
|
||||
blockedToday=$(cat ${piLog} | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l)
|
||||
else
|
||||
|
@ -49,7 +49,7 @@ CalcblockedToday(){
|
|||
fi
|
||||
}
|
||||
|
||||
CalcPercentBlockedToday(){
|
||||
CalcPercentBlockedToday() {
|
||||
if [ "$queriesToday" != "Err." ] && [ "$blockedToday" != "Err." ]; then
|
||||
if [ "$queriesToday" != 0 ]; then #Fixes divide by zero error :)
|
||||
#scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros
|
||||
|
@ -61,7 +61,7 @@ CalcPercentBlockedToday(){
|
|||
fi
|
||||
}
|
||||
|
||||
CheckIPv6(){
|
||||
CheckIPv6() {
|
||||
piholeIPv6file="/etc/pihole/.useIPv6"
|
||||
if [[ -f ${piholeIPv6file} ]];then
|
||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
||||
|
@ -69,7 +69,7 @@ CheckIPv6(){
|
|||
fi
|
||||
}
|
||||
|
||||
outputJSON(){
|
||||
outputJSON() {
|
||||
CalcQueriesToday
|
||||
CalcblockedToday
|
||||
CalcPercentBlockedToday
|
||||
|
@ -79,7 +79,7 @@ outputJSON(){
|
|||
printf '{"domains_being_blocked":"%s","dns_queries_today":"%s","ads_blocked_today":"%s","ads_percentage_today":"%s"}\n' "$blockedDomainsTotal" "$queriesToday" "$blockedToday" "$percentBlockedToday"
|
||||
}
|
||||
|
||||
normalChrono(){
|
||||
normalChrono() {
|
||||
for (( ; ; ))
|
||||
do
|
||||
clear
|
||||
|
@ -121,16 +121,17 @@ normalChrono(){
|
|||
done
|
||||
}
|
||||
|
||||
displayHelp(){
|
||||
echo "::: Displays stats about your piHole!"
|
||||
echo ":::"
|
||||
echo "::: Usage: sudo pihole -c [optional:-j]"
|
||||
echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds"
|
||||
echo ":::"
|
||||
echo "::: Options:"
|
||||
echo "::: -j, --json output stats as JSON formatted string"
|
||||
echo "::: -h, --help display this help text"
|
||||
|
||||
displayHelp() {
|
||||
cat << EOM
|
||||
::: Displays stats about your piHole!
|
||||
:::
|
||||
::: Usage: sudo pihole -c [optional:-j]
|
||||
::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds
|
||||
:::
|
||||
::: Options:
|
||||
::: -j, --json output stats as JSON formatted string
|
||||
::: -h, --help display this help text
|
||||
EOM
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
#/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
|
||||
|
@ -27,12 +27,14 @@ PIHOLELOG="/var/log/pihole.log"
|
|||
WHITELISTMATCHES="/tmp/whitelistmatches.list"
|
||||
|
||||
# Header info and introduction
|
||||
echo "::: Beginning Pi-hole debug at $(date)!"
|
||||
echo "::: This debugging process will collect information from your running configuration,"
|
||||
echo "::: and optionally upload the generated log to a unique and random directory on"
|
||||
echo "::: Termbin.com. NOTE: All log files auto-delete after 1 month and you are the only"
|
||||
echo "::: person who is given the unique URL. Please consider where you post this link."
|
||||
echo "::: "
|
||||
cat << EOM
|
||||
::: Beginning Pi-hole debug at $(date)!
|
||||
::: This debugging process will collect information from your running configuration,
|
||||
::: and optionally upload the generated log to a unique and random directory on
|
||||
::: Termbin.com. NOTE: All log files auto-delete after 1 month and you are the only
|
||||
::: person who is given the unique URL. Please consider where you post this link.
|
||||
:::
|
||||
EOM
|
||||
|
||||
|
||||
######## FIRST CHECK ########
|
||||
|
@ -61,11 +63,11 @@ else
|
|||
fi
|
||||
|
||||
### Private functions exist here ###
|
||||
function log_write {
|
||||
log_write() {
|
||||
echo "$1" >> "${DEBUG_LOG}"
|
||||
}
|
||||
|
||||
function version_check {
|
||||
version_check() {
|
||||
log_write "############################################################"
|
||||
log_write "########## Installed Versions ##########"
|
||||
log_write "############################################################"
|
||||
|
@ -83,7 +85,7 @@ function version_check {
|
|||
php_ver="$(php -v |& head -n1)" && log_write "${php_ver}" || log_write "PHP not installed."
|
||||
}
|
||||
|
||||
function distro_check {
|
||||
distro_check() {
|
||||
echo "############################################################" >> ${DEBUG_LOG}
|
||||
echo "######## Installed OS Distribution #########" >> ${DEBUG_LOG}
|
||||
echo "############################################################" >> ${DEBUG_LOG}
|
||||
|
@ -96,7 +98,7 @@ function distro_check {
|
|||
echo >> ${DEBUG_LOG}
|
||||
}
|
||||
|
||||
function ip_check {
|
||||
ip_check() {
|
||||
echo "############################################################" >> ${DEBUG_LOG}
|
||||
echo "######## IP Address Information #########" >> ${DEBUG_LOG}
|
||||
echo "############################################################" >> ${DEBUG_LOG}
|
||||
|
@ -166,7 +168,7 @@ function ip_check {
|
|||
echo >> ${DEBUG_LOG}
|
||||
}
|
||||
|
||||
function hostnameCheck {
|
||||
hostnameCheck() {
|
||||
echo "############################################################" >> ${DEBUG_LOG}
|
||||
echo "######## Hostname Information #########" >> ${DEBUG_LOG}
|
||||
echo "############################################################" >> ${DEBUG_LOG}
|
||||
|
@ -188,7 +190,7 @@ function hostnameCheck {
|
|||
fi
|
||||
}
|
||||
|
||||
function portCheck {
|
||||
portCheck() {
|
||||
echo "############################################################" >> ${DEBUG_LOG}
|
||||
echo "######## Open Port Information #########" >> ${DEBUG_LOG}
|
||||
echo "############################################################" >> ${DEBUG_LOG}
|
||||
|
@ -200,7 +202,7 @@ function portCheck {
|
|||
echo >> ${DEBUG_LOG}
|
||||
}
|
||||
|
||||
function testResolver {
|
||||
testResolver() {
|
||||
echo "############################################################" >> ${DEBUG_LOG}
|
||||
echo "############ Resolver Functions Check ############" >> ${DEBUG_LOG}
|
||||
echo "############################################################" >> ${DEBUG_LOG}
|
||||
|
@ -262,7 +264,7 @@ function testResolver {
|
|||
echo >> ${DEBUG_LOG}
|
||||
}
|
||||
|
||||
function checkProcesses {
|
||||
checkProcesses() {
|
||||
echo "#######################################" >> ${DEBUG_LOG}
|
||||
echo "########### Processes Check ###########" >> ${DEBUG_LOG}
|
||||
echo "#######################################" >> ${DEBUG_LOG}
|
||||
|
@ -279,7 +281,7 @@ function checkProcesses {
|
|||
echo >> ${DEBUG_LOG}
|
||||
}
|
||||
|
||||
function debugLighttpd {
|
||||
debugLighttpd() {
|
||||
echo "::: Writing lighttpd to debug log..."
|
||||
echo "#######################################" >> ${DEBUG_LOG}
|
||||
echo "############ lighttpd.conf ############" >> ${DEBUG_LOG}
|
||||
|
@ -420,7 +422,7 @@ fi
|
|||
|
||||
|
||||
# Continuously append the pihole.log file to the pihole_debug.log file
|
||||
function dumpPiHoleLog {
|
||||
dumpPiHoleLog() {
|
||||
trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT
|
||||
echo -e "::: Writing current Pi-hole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)"
|
||||
echo "#######################################" >> ${DEBUG_LOG}
|
||||
|
@ -439,7 +441,7 @@ function dumpPiHoleLog {
|
|||
}
|
||||
|
||||
# Anything to be done after capturing of pihole.log terminates
|
||||
function finalWork {
|
||||
finalWork() {
|
||||
echo "::: Finshed debugging!"
|
||||
echo "::: The debug log can be uploaded to Termbin.com for easier sharing."
|
||||
read -r -p "::: Would you like to upload the log? [y/N] " response
|
||||
|
|
|
@ -17,8 +17,7 @@ webInterfaceDir="/var/www/html/admin"
|
|||
piholeGitUrl="https://github.com/pi-hole/pi-hole.git"
|
||||
piholeFilesDir="/etc/.pihole"
|
||||
|
||||
spinner()
|
||||
{
|
||||
spinner() {
|
||||
local pid=$1
|
||||
local delay=0.50
|
||||
local spinstr='/-\|'
|
||||
|
@ -142,4 +141,4 @@ elif [[ ${piholeVersion} != ${piholeVersionLatest} && ${webVersion} != ${webVers
|
|||
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
|
||||
fi
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
latest=false
|
||||
current=false
|
||||
|
||||
normalOutput(){
|
||||
normalOutput() {
|
||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
||||
|
||||
|
@ -25,7 +25,7 @@ normalOutput(){
|
|||
echo "::: Web-Admin version is $webVersion (Latest version is $webVersionLatest)"
|
||||
}
|
||||
|
||||
webOutput(){
|
||||
webOutput() {
|
||||
for var in "$@"
|
||||
do
|
||||
case "$var" in
|
||||
|
@ -48,7 +48,7 @@ webOutput(){
|
|||
fi
|
||||
}
|
||||
|
||||
coreOutput(){
|
||||
coreOutput() {
|
||||
for var in "$@"
|
||||
do
|
||||
case "$var" in
|
||||
|
@ -71,21 +71,22 @@ coreOutput(){
|
|||
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
|
||||
helpFunc() {
|
||||
cat << EOM
|
||||
:::
|
||||
::: Show Pi-hole/Web Admin versions
|
||||
:::
|
||||
::: Usage: pihole -v [ -a | -p ] [ -l | -c ]
|
||||
:::
|
||||
::: Options:
|
||||
::: -a, --admin Show both current and latest versions of web admin
|
||||
::: -p, --pihole Show both current and latest versions of Pi-hole core files
|
||||
::: -l, --latest (Only after -a | -p) Return only latest version
|
||||
::: -c, --current (Only after -a | -p) Return only current version
|
||||
::: -h, --help Show this help dialog
|
||||
:::
|
||||
EOM
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
|
@ -99,4 +100,4 @@ do
|
|||
"-p" | "--pihole" ) shift; coreOutput "$@" ;;
|
||||
"-h" | "--help" ) helpFunc;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
|
|
|
@ -11,18 +11,19 @@
|
|||
# (at your option) any later version.
|
||||
|
||||
|
||||
helpFunc()
|
||||
{
|
||||
echo "::: Immediately whitelists one or more domains in the hosts file"
|
||||
echo ":::"
|
||||
echo "::: Usage: pihole -w domain1 [domain2 ...]"
|
||||
echo ":::"
|
||||
echo "::: Options:"
|
||||
echo "::: -d, --delmode Remove domains from the whitelist"
|
||||
echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq"
|
||||
echo "::: -q, --quiet output is less verbose"
|
||||
echo "::: -h, --help Show this help dialog"
|
||||
echo "::: -l, --list Display your whitelisted domains"
|
||||
helpFunc() {
|
||||
cat << EOM
|
||||
::: Immediately whitelists one or more domains in the hosts file
|
||||
:::
|
||||
::: Usage: pihole -w domain1 [domain2 ...]
|
||||
:::
|
||||
::: Options:
|
||||
::: -d, --delmode Remove domains from the whitelist
|
||||
::: -nr, --noreload Update Whitelist without refreshing dnsmasq
|
||||
::: -q, --quiet output is less verbose
|
||||
::: -h, --help Show this help dialog
|
||||
::: -l, --list Display your whitelisted domains
|
||||
EOM
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -52,7 +53,7 @@ HandleOther(){
|
|||
fi
|
||||
}
|
||||
|
||||
PopWhitelistFile(){
|
||||
PopWhitelistFile() {
|
||||
#check whitelist file exists, and if not, create it
|
||||
if [[ ! -f ${whitelist} ]];then
|
||||
touch ${whitelist}
|
||||
|
@ -67,7 +68,7 @@ PopWhitelistFile(){
|
|||
done
|
||||
}
|
||||
|
||||
AddDomain(){
|
||||
AddDomain() {
|
||||
#| sed 's/\./\\./g'
|
||||
bool=false
|
||||
|
||||
|
@ -88,7 +89,7 @@ AddDomain(){
|
|||
fi
|
||||
}
|
||||
|
||||
RemoveDomain(){
|
||||
RemoveDomain() {
|
||||
|
||||
bool=false
|
||||
grep -Ex -q "$1" ${whitelist} || bool=true
|
||||
|
@ -139,3 +140,4 @@ if ${reload}; then
|
|||
fi
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue