2016-08-26 22:10:22 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Pi-hole: A black hole for Internet advertisements
|
2017-02-22 17:55:20 +00:00
|
|
|
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
|
|
|
# Network-wide ad blocking via your own hardware.
|
|
|
|
#
|
2016-08-26 22:10:22 +00:00
|
|
|
# Controller for all pihole scripts and functions.
|
|
|
|
#
|
2017-02-22 17:55:20 +00:00
|
|
|
# This file is copyright under the latest version of the EUPL.
|
|
|
|
# Please see LICENSE file for your rights under this license.
|
|
|
|
|
2017-03-08 12:16:40 +00:00
|
|
|
readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
2017-01-02 13:27:13 +00:00
|
|
|
readonly wildcardlist="/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
2017-05-14 01:11:44 +00:00
|
|
|
|
2016-08-26 22:10:22 +00:00
|
|
|
# Must be root to use this tool
|
|
|
|
if [[ ! $EUID -eq 0 ]];then
|
2017-05-14 01:11:44 +00:00
|
|
|
if [[ -x "$(command -v sudo)" ]]; then
|
2016-11-02 16:36:30 +00:00
|
|
|
exec sudo bash "$0" "$@"
|
|
|
|
exit $?
|
|
|
|
else
|
|
|
|
echo "::: sudo is needed to run pihole commands. Please run this script as root or install sudo."
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-08-26 22:10:22 +00:00
|
|
|
fi
|
|
|
|
|
2016-11-16 20:34:43 +00:00
|
|
|
webpageFunc() {
|
2016-12-28 16:25:14 +00:00
|
|
|
source /opt/pihole/webpage.sh
|
|
|
|
main "$@"
|
2016-11-16 20:34:43 +00:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2016-10-15 16:25:17 +00:00
|
|
|
whitelistFunc() {
|
2016-11-02 17:39:27 +00:00
|
|
|
"${PI_HOLE_SCRIPT_DIR}"/list.sh "$@"
|
2016-11-02 16:36:30 +00:00
|
|
|
exit 0
|
2016-08-26 22:10:22 +00:00
|
|
|
}
|
|
|
|
|
2016-10-15 16:25:17 +00:00
|
|
|
blacklistFunc() {
|
2016-11-02 17:39:27 +00:00
|
|
|
"${PI_HOLE_SCRIPT_DIR}"/list.sh "$@"
|
2016-11-02 16:36:30 +00:00
|
|
|
exit 0
|
2016-08-26 22:10:22 +00:00
|
|
|
}
|
|
|
|
|
2016-12-31 12:49:04 +00:00
|
|
|
wildcardFunc() {
|
|
|
|
"${PI_HOLE_SCRIPT_DIR}"/list.sh "$@"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2016-10-15 16:25:17 +00:00
|
|
|
debugFunc() {
|
2017-02-26 23:36:53 +00:00
|
|
|
local automated
|
2017-02-27 19:03:57 +00:00
|
|
|
local web
|
|
|
|
|
|
|
|
# Pull off the `debug` leaving passed call augmentation flags in $1
|
2017-02-26 23:36:53 +00:00
|
|
|
shift
|
2017-02-27 19:40:20 +00:00
|
|
|
if [[ "$@" == *"-a"* ]]; then
|
2017-02-26 23:36:53 +00:00
|
|
|
automated="true"
|
|
|
|
fi
|
2017-02-27 19:40:20 +00:00
|
|
|
if [[ "$@" == *"-w"* ]]; then
|
2017-02-27 19:03:57 +00:00
|
|
|
web="true"
|
|
|
|
fi
|
|
|
|
|
|
|
|
AUTOMATED=${automated:-} WEBCALL=${web:-} "${PI_HOLE_SCRIPT_DIR}"/piholeDebug.sh
|
2016-11-02 16:36:30 +00:00
|
|
|
exit 0
|
2016-08-26 22:10:22 +00:00
|
|
|
}
|
|
|
|
|
2016-10-15 16:25:17 +00:00
|
|
|
flushFunc() {
|
2017-05-17 10:44:35 +00:00
|
|
|
"${PI_HOLE_SCRIPT_DIR}"/piholeLogFlush.sh "$@"
|
2016-11-02 16:36:30 +00:00
|
|
|
exit 0
|
2016-08-26 22:10:22 +00:00
|
|
|
}
|
|
|
|
|
2016-10-15 16:25:17 +00:00
|
|
|
updatePiholeFunc() {
|
2016-11-02 17:39:27 +00:00
|
|
|
"${PI_HOLE_SCRIPT_DIR}"/update.sh
|
2016-11-02 16:36:30 +00:00
|
|
|
exit 0
|
2016-08-26 22:10:22 +00:00
|
|
|
}
|
|
|
|
|
2016-10-15 16:25:17 +00:00
|
|
|
reconfigurePiholeFunc() {
|
2016-11-02 16:36:30 +00:00
|
|
|
/etc/.pihole/automated\ install/basic-install.sh --reconfigure
|
|
|
|
exit 0;
|
2016-10-15 16:07:08 +00:00
|
|
|
}
|
|
|
|
|
2016-10-15 16:25:17 +00:00
|
|
|
updateGravityFunc() {
|
2016-11-02 17:39:27 +00:00
|
|
|
"${PI_HOLE_SCRIPT_DIR}"/gravity.sh "$@"
|
2016-11-02 16:36:30 +00:00
|
|
|
exit 0
|
2016-08-26 22:10:22 +00:00
|
|
|
}
|
|
|
|
|
2017-05-27 20:42:44 +00:00
|
|
|
scanList(){
|
2016-12-06 12:18:01 +00:00
|
|
|
domain="${1}"
|
|
|
|
list="${2}"
|
|
|
|
method="${3}"
|
2017-05-27 20:42:44 +00:00
|
|
|
if [[ ${method} == "-exact" ]] ; then
|
|
|
|
grep -i -E "(^|\s)${domain}($|\s)" "${list}"
|
2016-12-06 12:18:01 +00:00
|
|
|
else
|
2017-05-27 20:42:44 +00:00
|
|
|
grep -i "${domain}" "${list}"
|
2016-12-06 12:18:01 +00:00
|
|
|
fi
|
2016-12-06 08:55:17 +00:00
|
|
|
}
|
|
|
|
|
2017-05-27 20:42:44 +00:00
|
|
|
processWildcards() {
|
|
|
|
IFS="." read -r -a array <<< "${1}"
|
|
|
|
for (( i=${#array[@]}-1; i>=0; i-- )); do
|
|
|
|
ar=""
|
|
|
|
for (( j=${#array[@]}-1; j>${#array[@]}-i-2; j-- )); do
|
|
|
|
if [[ $j == $((${#array[@]}-1)) ]]; then
|
|
|
|
ar="${array[$j]}"
|
|
|
|
else
|
|
|
|
ar="${array[$j]}.${ar}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo "${ar}"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-10-15 16:25:17 +00:00
|
|
|
queryFunc() {
|
2017-05-27 20:42:44 +00:00
|
|
|
domain="${2}"
|
2016-12-06 12:18:01 +00:00
|
|
|
method="${3}"
|
2017-05-27 20:42:44 +00:00
|
|
|
lists=( /etc/pihole/list.* /etc/pihole/blacklist.txt)
|
|
|
|
for list in ${lists[@]}; do
|
|
|
|
if [ -e "${list}" ]; then
|
|
|
|
result=$(scanList ${domain} ${list} ${method})
|
|
|
|
# Remove empty lines before couting number of results
|
|
|
|
count=$(sed '/^\s*$/d' <<< "$result" | wc -l)
|
|
|
|
echo "::: ${list} (${count} results)"
|
|
|
|
if [[ ${count} > 0 ]]; then
|
|
|
|
echo "${result}"
|
|
|
|
fi
|
|
|
|
echo ""
|
|
|
|
else
|
|
|
|
echo "::: ${list} does not exist"
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Scan for possible wildcard matches
|
|
|
|
if [ -e "${wildcardlist}" ]; then
|
|
|
|
local wildcards=($(processWildcards "${domain}"))
|
|
|
|
for domain in ${wildcards[@]}; do
|
|
|
|
result=$(scanList "\/${domain}\/" ${wildcardlist})
|
|
|
|
# Remove empty lines before couting number of results
|
|
|
|
count=$(sed '/^\s*$/d' <<< "$result" | wc -l)
|
|
|
|
if [[ ${count} > 0 ]]; then
|
|
|
|
echo "::: Wildcard blocking ${domain} (${count} results)"
|
|
|
|
echo "${result}"
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
done
|
2017-05-14 01:11:44 +00:00
|
|
|
fi
|
2016-11-02 16:36:30 +00:00
|
|
|
exit 0
|
2016-08-26 08:39:27 +00:00
|
|
|
}
|
|
|
|
|
2016-10-15 16:25:17 +00:00
|
|
|
chronometerFunc() {
|
2016-11-02 16:36:30 +00:00
|
|
|
shift
|
2016-11-02 17:39:27 +00:00
|
|
|
"${PI_HOLE_SCRIPT_DIR}"/chronometer.sh "$@"
|
2016-11-02 16:36:30 +00:00
|
|
|
exit 0
|
2016-08-26 22:10:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-15 16:25:17 +00:00
|
|
|
uninstallFunc() {
|
2016-11-02 17:39:27 +00:00
|
|
|
"${PI_HOLE_SCRIPT_DIR}"/uninstall.sh
|
2016-11-02 16:36:30 +00:00
|
|
|
exit 0
|
2016-08-26 22:10:22 +00:00
|
|
|
}
|
|
|
|
|
2016-10-15 16:25:17 +00:00
|
|
|
versionFunc() {
|
2016-11-02 16:36:30 +00:00
|
|
|
shift
|
2016-11-02 17:39:27 +00:00
|
|
|
"${PI_HOLE_SCRIPT_DIR}"/version.sh "$@"
|
2016-11-02 16:36:30 +00:00
|
|
|
exit 0
|
2016-08-26 22:10:22 +00:00
|
|
|
}
|
|
|
|
|
2016-10-20 12:45:20 +00:00
|
|
|
restartDNS() {
|
|
|
|
dnsmasqPid=$(pidof dnsmasq)
|
2017-05-14 01:11:44 +00:00
|
|
|
if [[ "${dnsmasqPid}" ]]; then
|
|
|
|
# Service already running - reload config
|
|
|
|
if [[ -x "$(command -v systemctl)" ]]; then
|
2016-10-20 12:45:20 +00:00
|
|
|
systemctl restart dnsmasq
|
|
|
|
else
|
|
|
|
service dnsmasq restart
|
|
|
|
fi
|
|
|
|
else
|
2017-05-14 01:11:44 +00:00
|
|
|
# Service not running, start it up
|
|
|
|
if [[ -x "$(command -v systemctl)" ]]; then
|
2016-10-20 12:45:20 +00:00
|
|
|
systemctl start dnsmasq
|
|
|
|
else
|
|
|
|
service dnsmasq start
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
piholeEnable() {
|
2017-05-14 01:53:40 +00:00
|
|
|
if [[ "${2}" == "-h" ]] || [[ "${2}" == "--help" ]]; then
|
2017-05-14 01:11:44 +00:00
|
|
|
echo "Usage: pihole disable [time]
|
|
|
|
Example: 'pihole disable', or 'pihole disable 5m'
|
|
|
|
Disable Pi-hole subsystems
|
|
|
|
|
|
|
|
Time:
|
|
|
|
#s Disable Pi-hole functionality for # second(s)
|
|
|
|
#m Disable Pi-hole functionality for # minute(s)"
|
|
|
|
exit 0
|
|
|
|
elif [[ "${1}" == "0" ]]; then
|
|
|
|
# Disable Pi-hole
|
2016-12-14 19:42:20 +00:00
|
|
|
sed -i 's/^addn-hosts=\/etc\/pihole\/gravity.list/#addn-hosts=\/etc\/pihole\/gravity.list/' /etc/dnsmasq.d/01-pihole.conf
|
2017-05-27 15:51:41 +00:00
|
|
|
if [[ -e "$wildcardlist" ]]; then
|
|
|
|
mv "$wildcardlist" "/etc/pihole/wildcard.list"
|
|
|
|
fi
|
2016-10-23 18:44:40 +00:00
|
|
|
echo "::: Blocking has been disabled!"
|
2017-05-14 01:11:44 +00:00
|
|
|
if [[ $# > 1 ]]; then
|
|
|
|
if [[ "${2}" == *"s"* ]]; then
|
2016-11-17 22:31:11 +00:00
|
|
|
tt=${2%"s"}
|
2016-11-18 11:16:10 +00:00
|
|
|
echo "::: Blocking will be re-enabled in ${tt} seconds"
|
2016-11-17 22:31:11 +00:00
|
|
|
nohup bash -c "sleep ${tt}; pihole enable" </dev/null &>/dev/null &
|
2017-05-14 01:11:44 +00:00
|
|
|
elif [[ "${2}" == *"m"* ]]; then
|
2016-11-17 22:31:11 +00:00
|
|
|
tt=${2%"m"}
|
2016-11-18 11:16:10 +00:00
|
|
|
echo "::: Blocking will be re-enabled in ${tt} minutes"
|
2016-11-17 22:31:11 +00:00
|
|
|
tt=$((${tt}*60))
|
|
|
|
nohup bash -c "sleep ${tt}; pihole enable" </dev/null &>/dev/null &
|
2016-11-17 21:58:00 +00:00
|
|
|
else
|
2016-11-17 22:31:11 +00:00
|
|
|
echo "::: Unknown format for delayed reactivation of the blocking!"
|
|
|
|
echo "::: Example:"
|
|
|
|
echo "::: pihole disable 5s - will disable blocking for 5 seconds"
|
|
|
|
echo "::: pihole disable 7m - will disable blocking for 7 minutes"
|
2016-11-17 22:36:53 +00:00
|
|
|
echo "::: Blocking will not automatically be re-enabled!"
|
2016-11-17 21:58:00 +00:00
|
|
|
fi
|
|
|
|
fi
|
2016-10-20 12:45:20 +00:00
|
|
|
else
|
2017-05-14 01:11:44 +00:00
|
|
|
# Enable Pi-hole
|
2016-10-23 18:44:40 +00:00
|
|
|
echo "::: Blocking has been enabled!"
|
2016-10-20 12:45:20 +00:00
|
|
|
sed -i 's/^#addn-hosts/addn-hosts/' /etc/dnsmasq.d/01-pihole.conf
|
2017-05-27 15:51:41 +00:00
|
|
|
if [[ -e "/etc/pihole/wildcard.list" ]]; then
|
|
|
|
mv "/etc/pihole/wildcard.list" "$wildcardlist"
|
|
|
|
fi
|
2016-10-20 12:45:20 +00:00
|
|
|
fi
|
|
|
|
restartDNS
|
|
|
|
}
|
|
|
|
|
2016-10-31 22:02:20 +00:00
|
|
|
piholeLogging() {
|
2016-11-02 09:35:48 +00:00
|
|
|
shift
|
2017-05-14 01:53:40 +00:00
|
|
|
if [[ "${1}" == "-h" ]] || [[ "${1}" == "--help" ]]; then
|
2017-05-14 01:11:44 +00:00
|
|
|
echo "Usage: pihole logging [options]
|
|
|
|
Example: 'pihole logging on'
|
|
|
|
Specify whether the Pi-hole log should be used
|
|
|
|
|
|
|
|
Options:
|
|
|
|
on Enable the Pi-hole log at /var/log/pihole.log
|
|
|
|
off Disable the Pi-hole log at /var/log/pihole.log"
|
|
|
|
exit 0
|
|
|
|
elif [[ "${1}" == "off" ]]; then
|
|
|
|
# Disable logging
|
2016-11-02 09:35:48 +00:00
|
|
|
sed -i 's/^log-queries/#log-queries/' /etc/dnsmasq.d/01-pihole.conf
|
|
|
|
sed -i 's/^QUERY_LOGGING=true/QUERY_LOGGING=false/' /etc/pihole/setupVars.conf
|
|
|
|
pihole -f
|
|
|
|
echo "::: Logging has been disabled!"
|
2017-05-14 01:11:44 +00:00
|
|
|
elif [[ "${1}" == "on" ]]; then
|
|
|
|
# Enable logging
|
2016-11-02 09:35:48 +00:00
|
|
|
sed -i 's/^#log-queries/log-queries/' /etc/dnsmasq.d/01-pihole.conf
|
|
|
|
sed -i 's/^QUERY_LOGGING=false/QUERY_LOGGING=true/' /etc/pihole/setupVars.conf
|
|
|
|
echo "::: Logging has been enabled!"
|
|
|
|
else
|
|
|
|
echo "::: Invalid option passed, please pass 'on' or 'off'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
restartDNS
|
2016-10-31 22:02:20 +00:00
|
|
|
}
|
|
|
|
|
2016-10-20 12:45:20 +00:00
|
|
|
piholeStatus() {
|
2017-05-14 01:11:44 +00:00
|
|
|
if [[ "$(netstat -plnt | grep -c ':53 ')" -gt "0" ]]; then
|
|
|
|
if [[ "${1}" != "web" ]]; then
|
2016-12-28 15:58:48 +00:00
|
|
|
echo "::: DNS service is running"
|
|
|
|
fi
|
|
|
|
else
|
2017-05-14 01:11:44 +00:00
|
|
|
if [[ "${1}" == "web" ]]; then
|
2016-12-28 15:58:48 +00:00
|
|
|
echo "-1";
|
|
|
|
else
|
|
|
|
echo "::: DNS service is NOT running"
|
|
|
|
fi
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
if [[ "$(grep -i "^#addn-hosts=/" /etc/dnsmasq.d/01-pihole.conf)" ]]; then
|
|
|
|
# List is commented out
|
|
|
|
if [[ "${1}" == "web" ]]; then
|
2016-10-23 18:33:28 +00:00
|
|
|
echo 0;
|
|
|
|
else
|
2016-10-23 18:47:31 +00:00
|
|
|
echo "::: Pi-hole blocking is Disabled";
|
2016-10-20 22:40:03 +00:00
|
|
|
fi
|
2017-05-14 01:11:44 +00:00
|
|
|
elif [[ "$(grep -i "^addn-hosts=/" /etc/dnsmasq.d/01-pihole.conf)" ]]; then
|
|
|
|
# List set
|
|
|
|
if [[ "${1}" == "web" ]]; then
|
2016-10-23 18:33:28 +00:00
|
|
|
echo 1;
|
|
|
|
else
|
2016-10-23 18:47:31 +00:00
|
|
|
echo "::: Pi-hole blocking is Enabled";
|
2016-10-20 12:45:20 +00:00
|
|
|
fi
|
2016-10-20 22:40:03 +00:00
|
|
|
else
|
2017-05-14 01:11:44 +00:00
|
|
|
# Addn-host not found
|
|
|
|
if [[ "${1}" == "web" ]]; then
|
2016-10-20 22:45:27 +00:00
|
|
|
echo 99
|
|
|
|
else
|
2016-10-21 01:15:11 +00:00
|
|
|
echo "::: No hosts file linked to dnsmasq, adding it in enabled state"
|
2016-10-20 22:45:27 +00:00
|
|
|
fi
|
2017-05-14 01:11:44 +00:00
|
|
|
# Add addn-host= to dnsmasq
|
2016-10-20 22:40:03 +00:00
|
|
|
echo "addn-hosts=/etc/pihole/gravity.list" >> /etc/dnsmasq.d/01-pihole.conf
|
|
|
|
restartDNS
|
2016-10-20 12:45:20 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-12-08 20:15:03 +00:00
|
|
|
tailFunc() {
|
2016-12-08 21:35:50 +00:00
|
|
|
echo "Press Ctrl-C to exit"
|
2016-12-08 20:15:03 +00:00
|
|
|
tail -F /var/log/pihole.log
|
|
|
|
exit 0
|
|
|
|
}
|
2016-10-20 12:45:20 +00:00
|
|
|
|
2017-03-08 12:16:40 +00:00
|
|
|
piholeCheckoutFunc() {
|
2017-05-14 02:22:19 +00:00
|
|
|
if [[ "$2" == "-h" ]] || [[ "$2" == "--help" ]]; then
|
2017-05-14 01:11:44 +00:00
|
|
|
echo "Usage: pihole checkout [repo] [branch]
|
|
|
|
Example: 'pihole checkout master' or 'pihole checkout core dev'
|
|
|
|
Switch Pi-hole subsystems to a different Github branch
|
|
|
|
|
|
|
|
Repositories:
|
|
|
|
core [branch] Change the branch of Pi-hole's core subsystem
|
|
|
|
web [branch] Change the branch of Admin Console subsystem
|
2017-05-14 15:17:04 +00:00
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
Branches:
|
|
|
|
master Update subsystems to the latest stable release
|
|
|
|
dev Update subsystems to the latest development release"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-03-08 12:16:40 +00:00
|
|
|
source "${PI_HOLE_SCRIPT_DIR}"/piholeCheckout.sh
|
2017-03-08 21:57:35 +00:00
|
|
|
shift
|
2017-03-08 12:16:40 +00:00
|
|
|
checkout "$@"
|
|
|
|
}
|
|
|
|
|
2017-05-13 19:08:21 +00:00
|
|
|
tricorderFunc() {
|
2017-05-18 02:53:32 +00:00
|
|
|
if [[ ! -p "/dev/stdin" ]]; then
|
2017-05-14 09:27:14 +00:00
|
|
|
echo "Please do not call Tricorder directly."
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-05-27 15:51:41 +00:00
|
|
|
|
2017-05-18 02:43:17 +00:00
|
|
|
if ! timeout 2 nc -z tricorder.pi-hole.net 9998 &> /dev/null; then
|
|
|
|
echo "Unable to connect to Pi-hole's Tricorder server."
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-05-14 09:27:14 +00:00
|
|
|
|
2017-05-13 19:08:21 +00:00
|
|
|
if command -v openssl &> /dev/null; then
|
|
|
|
openssl s_client -quiet -connect tricorder.pi-hole.net:9998 2> /dev/null < /dev/stdin
|
2017-05-18 02:43:17 +00:00
|
|
|
exit "$?"
|
2017-05-13 19:08:21 +00:00
|
|
|
else
|
2017-05-15 23:48:46 +00:00
|
|
|
echo "Your debug log will be transmitted unencrypted via plain-text"
|
|
|
|
echo "There is a possibility that this could be intercepted by a third party"
|
2017-05-14 09:27:14 +00:00
|
|
|
echo "If you wish to cancel, press Ctrl-C to exit within 10 seconds"
|
|
|
|
secs="10"
|
2017-05-18 02:53:32 +00:00
|
|
|
while [[ "$secs" -gt "0" ]]; do
|
2017-05-14 09:27:14 +00:00
|
|
|
echo -ne "."
|
|
|
|
sleep 1
|
|
|
|
: $((secs--))
|
|
|
|
done
|
|
|
|
echo " "
|
2017-05-15 23:48:46 +00:00
|
|
|
nc tricorder.pi-hole.net 9999 < /dev/stdin
|
2017-05-18 02:43:17 +00:00
|
|
|
exit "$?"
|
2017-05-13 19:08:21 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-10-15 16:25:17 +00:00
|
|
|
helpFunc() {
|
2017-05-14 01:11:44 +00:00
|
|
|
echo "Usage: pihole [options]
|
|
|
|
Example: 'pihole -w -h'
|
|
|
|
Add '-h' after specific commands for more information on usage
|
2017-05-14 15:17:04 +00:00
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
Whitelist/Blacklist Options:
|
|
|
|
-w, whitelist Whitelist domain(s)
|
|
|
|
-b, blacklist Blacklist domain(s)
|
|
|
|
-wild, wildcard Blacklist domain(s), and all its subdomains
|
|
|
|
Add '-h' for more info on whitelist/blacklist usage
|
|
|
|
|
|
|
|
Debugging Options:
|
|
|
|
-d, debug Start a debugging session
|
|
|
|
Add '-a' to enable automated debugging
|
|
|
|
-f, flush Flush the Pi-hole log
|
|
|
|
-r, reconfigure Reconfigure or Repair Pi-hole subsystems
|
|
|
|
-t, tail View the live output of the Pi-hole log
|
|
|
|
|
|
|
|
Options:
|
|
|
|
-a, admin Admin Console options
|
|
|
|
Add '-h' for more info on admin console usage
|
|
|
|
-c, chronometer Calculates stats and displays to an LCD
|
|
|
|
Add '-h' for more info on chronometer usage
|
|
|
|
-g, updateGravity Update the list of ad-serving domains
|
|
|
|
-h, --help, help Show this help dialog
|
|
|
|
-l, logging Specify whether the Pi-hole log should be used
|
|
|
|
Add '-h' for more info on logging usage
|
|
|
|
-q, query Query the adlists for a specified domain
|
|
|
|
Add '-exact' AFTER a specified domain for exact match
|
2017-05-14 15:17:04 +00:00
|
|
|
-up, updatePihole Update Pi-hole subsystems
|
2017-05-14 01:11:44 +00:00
|
|
|
-v, version Show installed versions of Pi-hole, Admin Console & FTL
|
2017-05-14 15:17:04 +00:00
|
|
|
Add '-h' for more info on version usage
|
2017-05-14 01:11:44 +00:00
|
|
|
uninstall Uninstall Pi-hole from your system
|
|
|
|
status Display the running status of Pi-hole subsystems
|
|
|
|
enable Enable Pi-hole subsystems
|
|
|
|
disable Disable Pi-hole subsystems
|
|
|
|
Add '-h' for more info on disable usage
|
|
|
|
restartdns Restart Pi-hole subsystems
|
|
|
|
checkout Switch Pi-hole subsystems to a different Github branch
|
|
|
|
Add '-h' for more info on checkout usage";
|
2016-12-01 20:21:08 +00:00
|
|
|
exit 0
|
2016-08-26 22:10:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ $# = 0 ]]; then
|
2016-11-02 16:36:30 +00:00
|
|
|
helpFunc
|
2016-08-26 22:10:22 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Handle redirecting to specific functions based on arguments
|
2016-10-22 06:17:14 +00:00
|
|
|
case "${1}" in
|
2016-11-02 16:36:30 +00:00
|
|
|
"-w" | "whitelist" ) whitelistFunc "$@";;
|
|
|
|
"-b" | "blacklist" ) blacklistFunc "$@";;
|
2016-12-31 12:49:04 +00:00
|
|
|
"-wild" | "wildcard" ) wildcardFunc "$@";;
|
2017-02-26 23:36:53 +00:00
|
|
|
"-d" | "debug" ) debugFunc "$@";;
|
2017-05-17 10:44:35 +00:00
|
|
|
"-f" | "flush" ) flushFunc "$@";;
|
2016-11-02 16:36:30 +00:00
|
|
|
"-up" | "updatePihole" ) updatePiholeFunc;;
|
|
|
|
"-r" | "reconfigure" ) reconfigurePiholeFunc;;
|
|
|
|
"-g" | "updateGravity" ) updateGravityFunc "$@";;
|
|
|
|
"-c" | "chronometer" ) chronometerFunc "$@";;
|
|
|
|
"-h" | "help" ) helpFunc;;
|
|
|
|
"-v" | "version" ) versionFunc "$@";;
|
|
|
|
"-q" | "query" ) queryFunc "$@";;
|
|
|
|
"-l" | "logging" ) piholeLogging "$@";;
|
|
|
|
"uninstall" ) uninstallFunc;;
|
|
|
|
"enable" ) piholeEnable 1;;
|
2017-05-14 01:11:44 +00:00
|
|
|
"disable" ) piholeEnable 0 "$2";;
|
2016-11-02 16:36:30 +00:00
|
|
|
"status" ) piholeStatus "$2";;
|
|
|
|
"restartdns" ) restartDNS;;
|
2016-11-20 14:15:27 +00:00
|
|
|
"-a" | "admin" ) webpageFunc "$@";;
|
2016-12-08 20:15:03 +00:00
|
|
|
"-t" | "tail" ) tailFunc;;
|
2017-03-08 12:16:40 +00:00
|
|
|
"checkout" ) piholeCheckoutFunc "$@";;
|
2017-06-03 17:13:40 +00:00
|
|
|
"tricorder" ) tricorderFunc;;
|
2016-11-02 16:36:30 +00:00
|
|
|
* ) helpFunc;;
|
2016-10-15 16:25:17 +00:00
|
|
|
esac
|