mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-25 00:30:29 +00:00
Update Help Output (#1467)
* File consistency * Tabs to 2 spaces * Corrected indenting * Double braced conditionals * Quoted variables within conditionals * Standardise core help text * Added help text for disable command * Added help text for logging command * Clean up * Fixed certain new lines and spaces * Sync with development branch * Formatting consistency * Tabs to 2 spaces * Corrected indenting * Double braced conditionals * Quoted variables within conditionals * Fixed certain newlines and spaces * Admin help text * Added help text for interface command * Sync with development branch * Formatting consistency * Tabs to 2 spaces * Fixed some wording * Fixed certain spaces * Formatting consistency * Minor wording changes * Tabs to 2 spaces * Corrected indenting * Double braced conditionals * Quoted variables within conditionals * Fixed certain newlines and spaces * Blacklist help text * Formatting consistency * Tabs to 2 spaces * Corrected indenting * Cronometer help text * Formatting consistency * Fixed certain newlines and spaces * Corrected indenting * Checkout warning alteration * Add checkout help text * Corrected help output
This commit is contained in:
parent
26fcb1b2a0
commit
b721ed49ab
6 changed files with 547 additions and 532 deletions
|
@ -8,101 +8,98 @@
|
|||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
#Functions##############################################################################################################
|
||||
# Functions
|
||||
piLog="/var/log/pihole.log"
|
||||
gravity="/etc/pihole/gravity.list"
|
||||
|
||||
. /etc/pihole/setupVars.conf
|
||||
|
||||
function GetFTLData {
|
||||
# Open connection to FTL
|
||||
exec 3<>/dev/tcp/localhost/"$(cat /var/run/pihole-FTL.port)"
|
||||
# Open connection to FTL
|
||||
exec 3<>/dev/tcp/localhost/"$(cat /var/run/pihole-FTL.port)"
|
||||
|
||||
# Test if connection is open
|
||||
if { >&3; } 2> /dev/null; then
|
||||
# Send command to FTL
|
||||
echo -e ">$1" >&3
|
||||
# Test if connection is open
|
||||
if { >&3; } 2> /dev/null; then
|
||||
# Send command to FTL
|
||||
echo -e ">$1" >&3
|
||||
|
||||
# Read input
|
||||
# Read input
|
||||
read -r -t 1 LINE <&3
|
||||
until [ ! $? ] || [[ "$LINE" == *"EOM"* ]]; do
|
||||
echo "$LINE" >&1
|
||||
read -r -t 1 LINE <&3
|
||||
until [ ! $? ] || [[ "$LINE" == *"EOM"* ]]; do
|
||||
echo "$LINE" >&1
|
||||
read -r -t 1 LINE <&3
|
||||
done
|
||||
done
|
||||
|
||||
# Close connection
|
||||
exec 3>&-
|
||||
exec 3<&-
|
||||
fi
|
||||
# Close connection
|
||||
exec 3>&-
|
||||
exec 3<&-
|
||||
fi
|
||||
}
|
||||
|
||||
outputJSON() {
|
||||
get_summary_data
|
||||
echo "{\"domains_being_blocked\":${domains_being_blocked_raw},\"dns_queries_today\":${dns_queries_today_raw},\"ads_blocked_today\":${ads_blocked_today_raw},\"ads_percentage_today\":${ads_percentage_today_raw}}"
|
||||
get_summary_data
|
||||
echo "{\"domains_being_blocked\":${domains_being_blocked_raw},\"dns_queries_today\":${dns_queries_today_raw},\"ads_blocked_today\":${ads_blocked_today_raw},\"ads_percentage_today\":${ads_percentage_today_raw}}"
|
||||
}
|
||||
|
||||
get_summary_data() {
|
||||
local summary=$(GetFTLData "stats")
|
||||
domains_being_blocked_raw=$(grep "domains_being_blocked" <<< "${summary}" | grep -Eo "[0-9]+$")
|
||||
domains_being_blocked=$(printf "%'.f" ${domains_being_blocked_raw})
|
||||
dns_queries_today_raw=$(grep "dns_queries_today" <<< "$summary" | grep -Eo "[0-9]+$")
|
||||
dns_queries_today=$(printf "%'.f" ${dns_queries_today_raw})
|
||||
ads_blocked_today_raw=$(grep "ads_blocked_today" <<< "$summary" | grep -Eo "[0-9]+$")
|
||||
ads_blocked_today=$(printf "%'.f" ${ads_blocked_today_raw})
|
||||
ads_percentage_today_raw=$(grep "ads_percentage_today" <<< "$summary" | grep -Eo "[0-9.]+$")
|
||||
LC_NUMERIC=C ads_percentage_today=$(printf "%'.f" ${ads_percentage_today_raw})
|
||||
local summary=$(GetFTLData "stats")
|
||||
domains_being_blocked_raw=$(grep "domains_being_blocked" <<< "${summary}" | grep -Eo "[0-9]+$")
|
||||
domains_being_blocked=$(printf "%'.f" ${domains_being_blocked_raw})
|
||||
dns_queries_today_raw=$(grep "dns_queries_today" <<< "$summary" | grep -Eo "[0-9]+$")
|
||||
dns_queries_today=$(printf "%'.f" ${dns_queries_today_raw})
|
||||
ads_blocked_today_raw=$(grep "ads_blocked_today" <<< "$summary" | grep -Eo "[0-9]+$")
|
||||
ads_blocked_today=$(printf "%'.f" ${ads_blocked_today_raw})
|
||||
ads_percentage_today_raw=$(grep "ads_percentage_today" <<< "$summary" | grep -Eo "[0-9.]+$")
|
||||
LC_NUMERIC=C ads_percentage_today=$(printf "%'.f" ${ads_percentage_today_raw})
|
||||
}
|
||||
|
||||
normalChrono() {
|
||||
for (( ; ; )); do
|
||||
get_summary_data
|
||||
domain=$(GetFTLData recentBlocked)
|
||||
clear
|
||||
# Displays a colorful Pi-hole logo
|
||||
echo " [0;1;35;95m_[0;1;31;91m__[0m [0;1;33;93m_[0m [0;1;34;94m_[0m [0;1;36;96m_[0m"
|
||||
echo "[0;1;31;91m|[0m [0;1;33;93m_[0m [0;1;32;92m(_[0;1;36;96m)_[0;1;34;94m__[0;1;35;95m|[0m [0;1;31;91m|_[0m [0;1;32;92m__[0;1;36;96m_|[0m [0;1;34;94m|[0;1;35;95m__[0;1;31;91m_[0m"
|
||||
echo "[0;1;33;93m|[0m [0;1;32;92m_[0;1;36;96m/[0m [0;1;34;94m|_[0;1;35;95m__[0;1;31;91m|[0m [0;1;33;93m'[0m [0;1;32;92m\/[0m [0;1;36;96m_[0m [0;1;34;94m\[0m [0;1;35;95m/[0m [0;1;31;91m-[0;1;33;93m_)[0m"
|
||||
echo "[0;1;32;92m|_[0;1;36;96m|[0m [0;1;34;94m|_[0;1;35;95m|[0m [0;1;33;93m|_[0;1;32;92m||[0;1;36;96m_\[0;1;34;94m__[0;1;35;95m_/[0;1;31;91m_\[0;1;33;93m__[0;1;32;92m_|[0m"
|
||||
echo ""
|
||||
echo " ${IPV4_ADDRESS}"
|
||||
echo ""
|
||||
uptime | cut -d' ' -f11-
|
||||
#uptime -p #Doesn't work on all versions of uptime
|
||||
uptime | awk -F'( |,|:)+' '{if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes."}'
|
||||
echo "-------------------------------"
|
||||
echo "Recently blocked:"
|
||||
echo " $domain"
|
||||
for (( ; ; )); do
|
||||
get_summary_data
|
||||
domain=$(GetFTLData recentBlocked)
|
||||
clear
|
||||
# Displays a colorful Pi-hole logo
|
||||
echo " [0;1;35;95m_[0;1;31;91m__[0m [0;1;33;93m_[0m [0;1;34;94m_[0m [0;1;36;96m_[0m"
|
||||
echo "[0;1;31;91m|[0m [0;1;33;93m_[0m [0;1;32;92m(_[0;1;36;96m)_[0;1;34;94m__[0;1;35;95m|[0m [0;1;31;91m|_[0m [0;1;32;92m__[0;1;36;96m_|[0m [0;1;34;94m|[0;1;35;95m__[0;1;31;91m_[0m"
|
||||
echo "[0;1;33;93m|[0m [0;1;32;92m_[0;1;36;96m/[0m [0;1;34;94m|_[0;1;35;95m__[0;1;31;91m|[0m [0;1;33;93m'[0m [0;1;32;92m\/[0m [0;1;36;96m_[0m [0;1;34;94m\[0m [0;1;35;95m/[0m [0;1;31;91m-[0;1;33;93m_)[0m"
|
||||
echo "[0;1;32;92m|_[0;1;36;96m|[0m [0;1;34;94m|_[0;1;35;95m|[0m [0;1;33;93m|_[0;1;32;92m||[0;1;36;96m_\[0;1;34;94m__[0;1;35;95m_/[0;1;31;91m_\[0;1;33;93m__[0;1;32;92m_|[0m"
|
||||
echo ""
|
||||
echo " ${IPV4_ADDRESS}"
|
||||
echo ""
|
||||
uptime | cut -d' ' -f11-
|
||||
#uptime -p # Doesn't work on all versions of uptime
|
||||
uptime | awk -F'( |,|:)+' '{if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes."}'
|
||||
echo "-------------------------------"
|
||||
echo "Recently blocked:"
|
||||
echo " $domain"
|
||||
|
||||
echo "Blocking: ${domains_being_blocked}"
|
||||
echo "Queries: ${dns_queries_today}"
|
||||
echo "Pi-holed: ${ads_blocked_today} (${ads_percentage_today}%)"
|
||||
echo "Blocking: ${domains_being_blocked}"
|
||||
echo "Queries: ${dns_queries_today}"
|
||||
echo "Pi-holed: ${ads_blocked_today} (${ads_percentage_today}%)"
|
||||
|
||||
sleep 5
|
||||
done
|
||||
sleep 5
|
||||
done
|
||||
}
|
||||
|
||||
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 0
|
||||
echo "Usage: pihole -c [options]
|
||||
Example: 'pihole -c -j'
|
||||
Calculates stats and displays to an LCD
|
||||
|
||||
Options:
|
||||
-j, --json Output stats as JSON formatted string
|
||||
-h, --help Display this help text"
|
||||
exit 0
|
||||
}
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
normalChrono
|
||||
normalChrono
|
||||
fi
|
||||
|
||||
for var in "$@"; do
|
||||
case "$var" in
|
||||
"-j" | "--json" ) outputJSON;;
|
||||
"-h" | "--help" ) displayHelp;;
|
||||
* ) exit 1;;
|
||||
esac
|
||||
case "$var" in
|
||||
"-j" | "--json" ) outputJSON;;
|
||||
"-h" | "--help" ) displayHelp;;
|
||||
* ) exit 1;;
|
||||
esac
|
||||
done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue