mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-22 15:20:14 +00:00
Remove ${SUDO} usages and root checks from scripts called by pihole
command as they should not be called directly.
This commit is contained in:
parent
461de48625
commit
090fbd04af
5 changed files with 51 additions and 95 deletions
|
@ -17,7 +17,7 @@ gravity="/etc/pihole/gravity.list"
|
|||
|
||||
today=$(date "+%b %e")
|
||||
|
||||
function CalcBlockedDomains(){
|
||||
CalcBlockedDomains(){
|
||||
CheckIPv6
|
||||
if [ -e "$gravity" ]; then
|
||||
#Are we IPV6 or IPV4?
|
||||
|
@ -33,7 +33,7 @@ function CalcBlockedDomains(){
|
|||
fi
|
||||
}
|
||||
|
||||
function CalcQueriesToday(){
|
||||
CalcQueriesToday(){
|
||||
if [ -e "$piLog" ];then
|
||||
queriesToday=$(cat "$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l)
|
||||
else
|
||||
|
@ -41,7 +41,7 @@ function CalcQueriesToday(){
|
|||
fi
|
||||
}
|
||||
|
||||
function 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 @@ function CalcblockedToday(){
|
|||
fi
|
||||
}
|
||||
|
||||
function 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 @@ function CalcPercentBlockedToday(){
|
|||
fi
|
||||
}
|
||||
|
||||
function 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 @@ function CheckIPv6(){
|
|||
fi
|
||||
}
|
||||
|
||||
function outputJSON(){
|
||||
outputJSON(){
|
||||
CalcQueriesToday
|
||||
CalcblockedToday
|
||||
CalcPercentBlockedToday
|
||||
|
@ -79,7 +79,7 @@ function outputJSON(){
|
|||
printf '{"domains_being_blocked":"%s","dns_queries_today":"%s","ads_blocked_today":"%s","ads_percentage_today":"%s"}\n' "$blockedDomainsTotal" "$queriesToday" "$blockedToday" "$percentBlockedToday"
|
||||
}
|
||||
|
||||
function normalChrono(){
|
||||
normalChrono(){
|
||||
for (( ; ; ))
|
||||
do
|
||||
clear
|
||||
|
@ -121,7 +121,7 @@ function normalChrono(){
|
|||
done
|
||||
}
|
||||
|
||||
function displayHelp(){
|
||||
displayHelp(){
|
||||
echo "::: Displays stats about your piHole!"
|
||||
echo ":::"
|
||||
echo "::: Usage: sudo pihole -c [optional:-j]"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue