Compare commits

...

3 Commits

Author SHA1 Message Date
Christian König
0841a7ad06 Fix typos
Signed-off-by: Christian König <ckoenig@posteo.de>
2021-10-31 18:30:40 +01:00
Christian König
496955a513 Hand arguments to functions
Signed-off-by: Christian König <ckoenig@posteo.de>
2021-10-26 21:11:38 +02:00
Christian König
49f218866f Document all pihole -a functions in help text and remove two obsolet functions
Signed-off-by: Christian König <ckoenig@posteo.de>
2021-10-26 20:09:33 +02:00

View File

@@ -34,18 +34,43 @@ fi
helpFunc() {
echo "Usage: pihole -a [options]
Example: pihole -a -p password
Set options for the Admin Console
Set options for the Admin Web Console
Add '-h' after specific commands for more information on usage
Options:
-p, password Set Admin Console password
-c, celsius Set Celsius as preferred temperature unit
-f, fahrenheit Set Fahrenheit as preferred temperature unit
-k, kelvin Set Kelvin as preferred temperature unit
-e, email Set an administrative contact address for the Block Page
-e, email Set an administrative contact address for the Block Page. Use -h for help
-h, --help Show this help dialog
-i, interface Specify dnsmasq's interface listening behavior
-i, interface Specify dnsmasq's interface listening behavior. Use -h for help
-l, privacylevel Set privacy level (0 = lowest, 3 = highest)
-t, teleporter Backup configuration as an archive"
-t, teleporter Backup configuration as an archive
poweroff Poweroff the system
reboot Reboot the system
restartdns Restarts Pi-hole
layout Set the web GUI layout [boxed/traditional]
theme Set the web GUI theme [default-light/default-dark/default-darker/default-auto]
adlist Manipulate adlists. Use -h for help
audit Adds a domain to the audit log. Seperate doamins by comma
clearaudit Remove all domains from the audit log.
addcustomdns Adds an entry to the Local DNS Records. Use -h for help
removecustomdns Removes an entry from the Local DNS Records. Use -h for help
addcustomcname Adds a local CNAME. Use -h for help
removecustomcname Removes a local CNAME. Use -h for help
enabledhcp Enable the DHCP server. Use -h for help
disabledhcp Disable the DHCP server
addstaticdhcp Adds a static DHCP lease. Use -h for help
removestaticdhcp Removes a static DHCP lease defind by [MAC]
setdns Set Pihole's upstream DNS server. Comma-seperate
individual server, use # to add specific port
setexcludedomains Set domains to exclude from the web GUI dashboard's Top Domains.
Comma-seperate individual domains
setexcludeclients Set clients to exclude from the web GUI dashboard's Top Clients.
Comma-seperate individual clients
setquerylog Set which queries should be shown in the query log. Use -h for help"
exit 0
}
@@ -364,6 +389,15 @@ RestartDNS() {
}
SetQueryLogOptions() {
if [[ "$3" == "-h" ]] || [[ "$3" == "--help" ]]; then
echo "Usage: pihole -a setquerylog [Value]
Set which queries should be shown in the query log.
Values are [all/permittedonly/blockedonly/nothing]
"
exit 0
fi
change_setting "API_QUERY_LOG_SHOW" "${args[2]}"
}
@@ -445,6 +479,19 @@ ra-param=*,0,0
}
EnableDHCP() {
if [[ "$3" == "-h" ]] || [[ "$3" == "--help" ]]; then
echo "Usage: pihole -a enabledhcp DHCP_START DHCP_END DHCP_ROUTER DHCP_LEASETIME PIHOLE_DOMAIN DHCP_IPv6 DHCP_rapid_commit
Set Pihole's built-in DHCP server.
DHCP_LEASETIME is in hours. 0 = infinite
DHCP_IPv6 [true/false]
DHCP_rapid_commit [true/false]"
exit 0
fi
change_setting "DHCP_ACTIVE" "true"
change_setting "DHCP_START" "${args[2]}"
change_setting "DHCP_END" "${args[3]}"
@@ -513,6 +560,18 @@ CustomizeAdLists() {
local comment
comment="${args[4]}"
if [[ "$3" == "-h" ]] || [[ "$3" == "--help" ]]; then
echo "Usage: pihole -a adlist [action] [address]
Modify Pi-hole's adlists.
Action:
add Add an adlist. Append the optional argument [comment] to add an comment
del Delete an adlist
enable Enable an adlist
disbale Disable an adlist"
exit 0
fi
if CheckUrl "${address}"; then
if [[ "${args[2]}" == "enable" ]]; then
sqlite3 "${gravityDBfile}" "UPDATE adlist SET enabled = 1 WHERE address = '${address}'"
@@ -532,30 +591,19 @@ CustomizeAdLists() {
fi
}
SetPrivacyMode() {
if [[ "${args[2]}" == "true" ]]; then
change_setting "API_PRIVACY_MODE" "true"
else
change_setting "API_PRIVACY_MODE" "false"
fi
}
ResolutionSettings() {
typ="${args[2]}"
state="${args[3]}"
if [[ "${typ}" == "forward" ]]; then
change_setting "API_GET_UPSTREAM_DNS_HOSTNAME" "${state}"
elif [[ "${typ}" == "clients" ]]; then
change_setting "API_GET_CLIENT_HOSTNAME" "${state}"
fi
}
AddDHCPStaticAddress() {
mac="${args[2]}"
ip="${args[3]}"
host="${args[4]}"
if [[ "$3" == "-h" ]] || [[ "$3" == "--help" ]]; then
echo "Usage: pihole -a addstaticdhcp [MAC] [IP] [HOSTNAME]
Set an static DHCP lease."
exit 0
fi
if [[ "${ip}" == "noip" ]]; then
# Static host name
echo "dhcp-host=${mac},${host}" >> "${dhcpstaticconfig}"
@@ -711,6 +759,17 @@ AddCustomDNSAddress() {
host="${args[3]}"
reload="${args[4]}"
if [[ "$3" == "-h" ]] || [[ "$3" == "--help" ]]; then
echo "Usage: pihole -a addcustomdns [IP] [HOSTNAME]
Add a Local DNS Record.
Optionally append 'false' to suppress restarting Pi-hole.
Note: added DNS records wont't have an effect until Pi-hole is
restarted.
"
exit 0
fi
validHost="$(checkDomain "${host}")"
if [[ -n "${validHost}" ]]; then
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
@@ -737,6 +796,17 @@ RemoveCustomDNSAddress() {
host="${args[3]}"
reload="${args[4]}"
if [[ "$3" == "-h" ]] || [[ "$3" == "--help" ]]; then
echo "Usage: pihole -a removecustomdns [IP] [HOSTNAME]
Remove a Local DNS Record.
Optionally append 'false' to suppress restarting Pi-hole.
Note: added DNS records wont't have an effect until Pi-hole is
restarted.
"
exit 0
fi
validHost="$(checkDomain "${host}")"
if [[ -n "${validHost}" ]]; then
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
@@ -763,6 +833,17 @@ AddCustomCNAMERecord() {
target="${args[3]}"
reload="${args[4]}"
if [[ "$3" == "-h" ]] || [[ "$3" == "--help" ]]; then
echo "Usage: pihole -a addcustomcname [DOMAIN] [TARGET]
Add a local CNAME record for Domain => Target
Optionally append 'false' to suppress restarting Pi-hole.
Note: added CNAME records wont't have an effect until Pi-hole is
restarted.
"
exit 0
fi
validDomain="$(checkDomain "${domain}")"
if [[ -n "${validDomain}" ]]; then
validTarget="$(checkDomain "${target}")"
@@ -789,6 +870,17 @@ RemoveCustomCNAMERecord() {
target="${args[3]}"
reload="${args[4]}"
if [[ "$3" == "-h" ]] || [[ "$3" == "--help" ]]; then
echo "Usage: pihole -a removecustomcname [DOMAIN] [TARGET]
Remove the local CNAME record for Domain => Target
Optionally append 'false' to suppress restarting Pi-hole.
Note: added CNAME records wont't have an effect until Pi-hole is
restarted.
"
exit 0
fi
validDomain="$(checkDomain "${domain}")"
if [[ -n "${validDomain}" ]]; then
validTarget="$(checkDomain "${target}")"
@@ -823,27 +915,25 @@ main() {
"poweroff" ) Poweroff;;
"reboot" ) Reboot;;
"restartdns" ) RestartDNS;;
"setquerylog" ) SetQueryLogOptions;;
"enabledhcp" ) EnableDHCP;;
"setquerylog" ) SetQueryLogOptions "$@";;
"enabledhcp" ) EnableDHCP"$@";;
"disabledhcp" ) DisableDHCP;;
"layout" ) SetWebUILayout;;
"theme" ) SetWebUITheme;;
"-h" | "--help" ) helpFunc;;
"privacymode" ) SetPrivacyMode;;
"resolve" ) ResolutionSettings;;
"addstaticdhcp" ) AddDHCPStaticAddress;;
"addstaticdhcp" ) AddDHCPStaticAddress "$@";;
"removestaticdhcp" ) RemoveDHCPStaticAddress;;
"-e" | "email" ) SetAdminEmail "$3";;
"-i" | "interface" ) SetListeningMode "$@";;
"-t" | "teleporter" ) Teleporter;;
"adlist" ) CustomizeAdLists;;
"adlist" ) CustomizeAdLists "$@";;
"audit" ) addAudit "$@";;
"clearaudit" ) clearAudit;;
"-l" | "privacylevel" ) SetPrivacyLevel;;
"addcustomdns" ) AddCustomDNSAddress;;
"removecustomdns" ) RemoveCustomDNSAddress;;
"addcustomcname" ) AddCustomCNAMERecord;;
"removecustomcname" ) RemoveCustomCNAMERecord;;
"addcustomdns" ) AddCustomDNSAddress "$@";;
"removecustomdns" ) RemoveCustomDNSAddress "$@";;
"addcustomcname" ) AddCustomCNAMERecord "$@";;
"removecustomcname" ) RemoveCustomCNAMERecord "$@";;
* ) helpFunc;;
esac