2016-11-16 20:34:43 +00:00
|
|
|
#!/usr/bin/env bash
|
2017-09-14 14:24:29 +00:00
|
|
|
# shellcheck disable=SC1090
|
|
|
|
|
2016-11-16 20:34:43 +00:00
|
|
|
# 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-11-16 21:13:47 +00:00
|
|
|
# Web interface settings
|
2016-11-16 20:34:43 +00:00
|
|
|
#
|
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.
|
|
|
|
|
2016-12-28 02:14:47 +00:00
|
|
|
readonly setupVars="/etc/pihole/setupVars.conf"
|
|
|
|
readonly dnsmasqconfig="/etc/dnsmasq.d/01-pihole.conf"
|
|
|
|
readonly dhcpconfig="/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
2018-04-04 11:12:39 +00:00
|
|
|
readonly FTLconf="/etc/pihole/pihole-FTL.conf"
|
2017-01-25 09:33:25 +00:00
|
|
|
# 03 -> wildcards
|
|
|
|
readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
|
2019-08-24 11:33:32 +00:00
|
|
|
readonly PI_HOLE_BIN_DIR="/usr/local/bin"
|
2019-10-27 00:07:08 +00:00
|
|
|
readonly dnscustomfile="/etc/pihole/custom.list"
|
2016-12-28 02:14:47 +00:00
|
|
|
|
2019-04-28 19:39:06 +00:00
|
|
|
readonly gravityDBfile="/etc/pihole/gravity.db"
|
|
|
|
|
2017-06-21 11:49:05 +00:00
|
|
|
coltable="/opt/pihole/COL_TABLE"
|
|
|
|
if [[ -f ${coltable} ]]; then
|
2018-07-20 20:57:15 +00:00
|
|
|
source ${coltable}
|
2017-06-21 11:49:05 +00:00
|
|
|
fi
|
|
|
|
|
2016-11-16 20:34:43 +00:00
|
|
|
helpFunc() {
|
2018-07-20 20:57:15 +00:00
|
|
|
echo "Usage: pihole -a [options]
|
2017-05-14 01:11:44 +00:00
|
|
|
Example: pihole -a -p password
|
|
|
|
Set options for the Admin Console
|
|
|
|
|
|
|
|
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
|
2017-07-26 17:00:08 +00:00
|
|
|
-r, hostrecord Add a name to the DNS associated to an IPv4/IPv6 address
|
2017-09-14 14:24:29 +00:00
|
|
|
-e, email Set an administrative contact address for the Block Page
|
2017-05-14 01:11:44 +00:00
|
|
|
-h, --help Show this help dialog
|
|
|
|
-i, interface Specify dnsmasq's interface listening behavior
|
2018-12-10 15:18:25 +00:00
|
|
|
-l, privacylevel Set privacy level (0 = lowest, 4 = highest)"
|
2018-07-20 20:57:15 +00:00
|
|
|
exit 0
|
2016-11-16 20:34:43 +00:00
|
|
|
}
|
|
|
|
|
2016-12-28 02:14:47 +00:00
|
|
|
add_setting() {
|
2018-07-20 20:57:15 +00:00
|
|
|
echo "${1}=${2}" >> "${setupVars}"
|
2016-12-28 02:14:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete_setting() {
|
2018-07-20 20:57:15 +00:00
|
|
|
sed -i "/${1}/d" "${setupVars}"
|
2016-12-28 02:14:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
change_setting() {
|
2018-07-20 20:57:15 +00:00
|
|
|
delete_setting "${1}"
|
|
|
|
add_setting "${1}" "${2}"
|
2016-12-28 02:14:47 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 11:12:39 +00:00
|
|
|
addFTLsetting() {
|
2018-07-20 20:57:15 +00:00
|
|
|
echo "${1}=${2}" >> "${FTLconf}"
|
2018-04-04 11:12:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
deleteFTLsetting() {
|
2018-07-20 20:57:15 +00:00
|
|
|
sed -i "/${1}/d" "${FTLconf}"
|
2018-04-04 11:12:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
changeFTLsetting() {
|
2018-07-20 20:57:15 +00:00
|
|
|
deleteFTLsetting "${1}"
|
|
|
|
addFTLsetting "${1}" "${2}"
|
2018-04-04 11:12:39 +00:00
|
|
|
}
|
|
|
|
|
2016-12-28 02:14:47 +00:00
|
|
|
add_dnsmasq_setting() {
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${2}" != "" ]]; then
|
|
|
|
echo "${1}=${2}" >> "${dnsmasqconfig}"
|
|
|
|
else
|
|
|
|
echo "${1}" >> "${dnsmasqconfig}"
|
|
|
|
fi
|
2016-12-28 02:14:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete_dnsmasq_setting() {
|
2018-07-20 20:57:15 +00:00
|
|
|
sed -i "/${1}/d" "${dnsmasqconfig}"
|
2016-12-28 02:14:47 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
SetTemperatureUnit() {
|
2018-07-20 20:57:15 +00:00
|
|
|
change_setting "TEMPERATUREUNIT" "${unit}"
|
|
|
|
echo -e " ${TICK} Set temperature unit to ${unit}"
|
2016-11-16 20:34:43 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
HashPassword() {
|
2018-07-20 20:57:15 +00:00
|
|
|
# Compute password hash twice to avoid rainbow table vulnerability
|
2019-08-14 21:28:13 +00:00
|
|
|
return=$(echo -n "${1}" | sha256sum | sed 's/\s.*$//')
|
|
|
|
return=$(echo -n "${return}" | sha256sum | sed 's/\s.*$//')
|
|
|
|
echo "${return}"
|
2017-05-02 21:24:37 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
SetWebPassword() {
|
2018-07-20 20:57:15 +00:00
|
|
|
if [ "${SUDO_USER}" == "www-data" ]; then
|
|
|
|
echo "Security measure: user www-data is not allowed to change webUI password!"
|
|
|
|
echo "Exiting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${SUDO_USER}" == "lighttpd" ]; then
|
|
|
|
echo "Security measure: user lighttpd is not allowed to change webUI password!"
|
|
|
|
echo "Exiting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( ${#args[2]} > 0 )) ; then
|
|
|
|
readonly PASSWORD="${args[2]}"
|
|
|
|
readonly CONFIRM="${PASSWORD}"
|
|
|
|
else
|
|
|
|
# Prevents a bug if the user presses Ctrl+C and it continues to hide the text typed.
|
|
|
|
# So we reset the terminal via stty if the user does press Ctrl+C
|
|
|
|
trap '{ echo -e "\nNo password will be set" ; stty sane ; exit 1; }' INT
|
2018-10-26 18:17:49 +00:00
|
|
|
read -s -r -p "Enter New Password (Blank for no password): " PASSWORD
|
2018-07-20 20:57:15 +00:00
|
|
|
echo ""
|
2017-05-04 09:43:48 +00:00
|
|
|
|
|
|
|
if [ "${PASSWORD}" == "" ]; then
|
2018-07-20 20:57:15 +00:00
|
|
|
change_setting "WEBPASSWORD" ""
|
|
|
|
echo -e " ${TICK} Password Removed"
|
|
|
|
exit 0
|
2017-05-04 09:43:48 +00:00
|
|
|
fi
|
|
|
|
|
2018-10-26 18:17:49 +00:00
|
|
|
read -s -r -p "Confirm Password: " CONFIRM
|
2017-05-04 09:43:48 +00:00
|
|
|
echo ""
|
2018-07-20 20:57:15 +00:00
|
|
|
fi
|
2017-03-27 17:37:19 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [ "${PASSWORD}" == "${CONFIRM}" ] ; then
|
2018-10-21 00:08:22 +00:00
|
|
|
# We do not wrap this in brackets, otherwise BASH will expand any appropriate syntax
|
|
|
|
hash=$(HashPassword "$PASSWORD")
|
2018-07-20 20:57:15 +00:00
|
|
|
# Save hash to file
|
|
|
|
change_setting "WEBPASSWORD" "${hash}"
|
|
|
|
echo -e " ${TICK} New password set"
|
|
|
|
else
|
|
|
|
echo -e " ${CROSS} Passwords don't match. Your password has not been changed"
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-11-16 20:34:43 +00:00
|
|
|
}
|
|
|
|
|
2016-12-28 02:14:47 +00:00
|
|
|
ProcessDNSSettings() {
|
2018-07-20 20:57:15 +00:00
|
|
|
source "${setupVars}"
|
|
|
|
|
|
|
|
delete_dnsmasq_setting "server"
|
|
|
|
|
|
|
|
COUNTER=1
|
2019-08-14 21:28:13 +00:00
|
|
|
while true ; do
|
2018-07-20 20:57:15 +00:00
|
|
|
var=PIHOLE_DNS_${COUNTER}
|
|
|
|
if [ -z "${!var}" ]; then
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
add_dnsmasq_setting "server" "${!var}"
|
2019-08-14 21:28:13 +00:00
|
|
|
(( COUNTER++ ))
|
2018-07-20 20:57:15 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# The option LOCAL_DNS_PORT is deprecated
|
|
|
|
# We apply it once more, and then convert it into the current format
|
2019-08-14 21:28:13 +00:00
|
|
|
if [ -n "${LOCAL_DNS_PORT}" ]; then
|
2018-07-20 20:57:15 +00:00
|
|
|
add_dnsmasq_setting "server" "127.0.0.1#${LOCAL_DNS_PORT}"
|
|
|
|
add_setting "PIHOLE_DNS_${COUNTER}" "127.0.0.1#${LOCAL_DNS_PORT}"
|
|
|
|
delete_setting "LOCAL_DNS_PORT"
|
|
|
|
fi
|
2018-04-18 15:12:20 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
delete_dnsmasq_setting "domain-needed"
|
2016-12-28 02:14:47 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${DNS_FQDN_REQUIRED}" == true ]]; then
|
|
|
|
add_dnsmasq_setting "domain-needed"
|
|
|
|
fi
|
2016-12-28 02:14:47 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
delete_dnsmasq_setting "bogus-priv"
|
2016-12-28 02:14:47 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${DNS_BOGUS_PRIV}" == true ]]; then
|
|
|
|
add_dnsmasq_setting "bogus-priv"
|
|
|
|
fi
|
2016-12-28 02:14:47 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
delete_dnsmasq_setting "dnssec"
|
|
|
|
delete_dnsmasq_setting "trust-anchor="
|
2017-01-12 15:02:41 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${DNSSEC}" == true ]]; then
|
|
|
|
echo "dnssec
|
2017-12-18 21:14:28 +00:00
|
|
|
trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D
|
2017-01-12 15:02:41 +00:00
|
|
|
" >> "${dnsmasqconfig}"
|
2018-07-20 20:57:15 +00:00
|
|
|
fi
|
2017-01-12 15:02:41 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
delete_dnsmasq_setting "host-record"
|
2017-02-22 13:43:07 +00:00
|
|
|
|
2019-08-14 21:28:13 +00:00
|
|
|
if [ -n "${HOSTRECORD}" ]; then
|
2018-07-20 20:57:15 +00:00
|
|
|
add_dnsmasq_setting "host-record" "${HOSTRECORD}"
|
|
|
|
fi
|
2017-02-22 13:43:07 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
# Setup interface listening behavior of dnsmasq
|
|
|
|
delete_dnsmasq_setting "interface"
|
|
|
|
delete_dnsmasq_setting "local-service"
|
2017-03-01 09:46:20 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${DNSMASQ_LISTENING}" == "all" ]]; then
|
|
|
|
# Listen on all interfaces, permit all origins
|
|
|
|
add_dnsmasq_setting "except-interface" "nonexisting"
|
|
|
|
elif [[ "${DNSMASQ_LISTENING}" == "local" ]]; then
|
|
|
|
# Listen only on all interfaces, but only local subnets
|
|
|
|
add_dnsmasq_setting "local-service"
|
|
|
|
else
|
|
|
|
# Listen only on one interface
|
|
|
|
# Use eth0 as fallback interface if interface is missing in setupVars.conf
|
|
|
|
if [ -z "${PIHOLE_INTERFACE}" ]; then
|
|
|
|
PIHOLE_INTERFACE="eth0"
|
|
|
|
fi
|
2018-01-07 13:34:02 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
add_dnsmasq_setting "interface" "${PIHOLE_INTERFACE}"
|
|
|
|
fi
|
2017-03-01 09:46:20 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${CONDITIONAL_FORWARDING}" == true ]]; then
|
|
|
|
add_dnsmasq_setting "server=/${CONDITIONAL_FORWARDING_DOMAIN}/${CONDITIONAL_FORWARDING_IP}"
|
|
|
|
add_dnsmasq_setting "server=/${CONDITIONAL_FORWARDING_REVERSE}/${CONDITIONAL_FORWARDING_IP}"
|
|
|
|
fi
|
2019-09-07 21:11:20 +00:00
|
|
|
|
|
|
|
# Prevent Firefox from automatically switching over to DNS-over-HTTPS
|
|
|
|
# This follows https://support.mozilla.org/en-US/kb/configuring-networks-disable-dns-over-https
|
|
|
|
# (sourced 7th September 2019)
|
|
|
|
add_dnsmasq_setting "server=/use-application-dns.net/"
|
2016-12-28 02:14:47 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
SetDNSServers() {
|
2018-07-20 20:57:15 +00:00
|
|
|
# Save setting to file
|
|
|
|
delete_setting "PIHOLE_DNS"
|
|
|
|
IFS=',' read -r -a array <<< "${args[2]}"
|
|
|
|
for index in "${!array[@]}"
|
|
|
|
do
|
|
|
|
add_setting "PIHOLE_DNS_$((index+1))" "${array[index]}"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ "${args[3]}" == "domain-needed" ]]; then
|
|
|
|
change_setting "DNS_FQDN_REQUIRED" "true"
|
|
|
|
else
|
|
|
|
change_setting "DNS_FQDN_REQUIRED" "false"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${args[4]}" == "bogus-priv" ]]; then
|
|
|
|
change_setting "DNS_BOGUS_PRIV" "true"
|
|
|
|
else
|
|
|
|
change_setting "DNS_BOGUS_PRIV" "false"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${args[5]}" == "dnssec" ]]; then
|
|
|
|
change_setting "DNSSEC" "true"
|
|
|
|
else
|
|
|
|
change_setting "DNSSEC" "false"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${args[6]}" == "conditional_forwarding" ]]; then
|
|
|
|
change_setting "CONDITIONAL_FORWARDING" "true"
|
|
|
|
change_setting "CONDITIONAL_FORWARDING_IP" "${args[7]}"
|
|
|
|
change_setting "CONDITIONAL_FORWARDING_DOMAIN" "${args[8]}"
|
|
|
|
change_setting "CONDITIONAL_FORWARDING_REVERSE" "${args[9]}"
|
|
|
|
else
|
|
|
|
change_setting "CONDITIONAL_FORWARDING" "false"
|
|
|
|
delete_setting "CONDITIONAL_FORWARDING_IP"
|
|
|
|
delete_setting "CONDITIONAL_FORWARDING_DOMAIN"
|
|
|
|
delete_setting "CONDITIONAL_FORWARDING_REVERSE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
ProcessDNSSettings
|
|
|
|
|
|
|
|
# Restart dnsmasq to load new configuration
|
|
|
|
RestartDNS
|
2016-12-11 15:54:27 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
SetExcludeDomains() {
|
2018-07-20 20:57:15 +00:00
|
|
|
change_setting "API_EXCLUDE_DOMAINS" "${args[2]}"
|
2016-12-11 18:30:04 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
SetExcludeClients() {
|
2018-07-20 20:57:15 +00:00
|
|
|
change_setting "API_EXCLUDE_CLIENTS" "${args[2]}"
|
2016-12-11 18:30:04 +00:00
|
|
|
}
|
|
|
|
|
2017-09-08 17:33:06 +00:00
|
|
|
Poweroff(){
|
2018-07-20 20:57:15 +00:00
|
|
|
nohup bash -c "sleep 5; poweroff" &> /dev/null </dev/null &
|
2017-04-11 17:04:44 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
Reboot() {
|
2018-07-20 20:57:15 +00:00
|
|
|
nohup bash -c "sleep 5; reboot" &> /dev/null </dev/null &
|
2016-12-11 21:33:27 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
RestartDNS() {
|
2019-08-24 11:33:32 +00:00
|
|
|
"${PI_HOLE_BIN_DIR}"/pihole restartdns
|
2016-12-12 09:38:21 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
SetQueryLogOptions() {
|
2018-07-20 20:57:15 +00:00
|
|
|
change_setting "API_QUERY_LOG_SHOW" "${args[2]}"
|
2016-12-28 02:14:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ProcessDHCPSettings() {
|
2018-07-20 20:57:15 +00:00
|
|
|
source "${setupVars}"
|
2017-01-03 12:34:01 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${DHCP_ACTIVE}" == "true" ]]; then
|
2018-01-07 13:36:03 +00:00
|
|
|
interface="${PIHOLE_INTERFACE}"
|
2017-01-02 09:50:59 +00:00
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
# Use eth0 as fallback interface
|
|
|
|
if [ -z ${interface} ]; then
|
2018-07-20 20:57:15 +00:00
|
|
|
interface="eth0"
|
2017-05-14 01:11:44 +00:00
|
|
|
fi
|
2016-12-28 02:14:47 +00:00
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
if [[ "${PIHOLE_DOMAIN}" == "" ]]; then
|
2018-07-20 20:57:15 +00:00
|
|
|
PIHOLE_DOMAIN="lan"
|
|
|
|
change_setting "PIHOLE_DOMAIN" "${PIHOLE_DOMAIN}"
|
2017-05-14 01:11:44 +00:00
|
|
|
fi
|
2017-01-02 10:08:54 +00:00
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
if [[ "${DHCP_LEASETIME}" == "0" ]]; then
|
2018-07-20 20:57:15 +00:00
|
|
|
leasetime="infinite"
|
2017-05-14 01:11:44 +00:00
|
|
|
elif [[ "${DHCP_LEASETIME}" == "" ]]; then
|
2018-07-20 20:57:15 +00:00
|
|
|
leasetime="24"
|
|
|
|
change_setting "DHCP_LEASETIME" "${leasetime}"
|
2017-07-28 18:40:13 +00:00
|
|
|
elif [[ "${DHCP_LEASETIME}" == "24h" ]]; then
|
2018-07-20 20:57:15 +00:00
|
|
|
#Installation is affected by known bug, introduced in a previous version.
|
|
|
|
#This will automatically clean up setupVars.conf and remove the unnecessary "h"
|
|
|
|
leasetime="24"
|
|
|
|
change_setting "DHCP_LEASETIME" "${leasetime}"
|
2017-05-14 01:11:44 +00:00
|
|
|
else
|
2018-07-20 20:57:15 +00:00
|
|
|
leasetime="${DHCP_LEASETIME}h"
|
2017-05-14 01:11:44 +00:00
|
|
|
fi
|
2016-12-29 14:19:44 +00:00
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
# Write settings to file
|
|
|
|
echo "###############################################################################
|
2016-12-28 02:14:47 +00:00
|
|
|
# DHCP SERVER CONFIG FILE AUTOMATICALLY POPULATED BY PI-HOLE WEB INTERFACE. #
|
|
|
|
# ANY CHANGES MADE TO THIS FILE WILL BE LOST ON CHANGE #
|
|
|
|
###############################################################################
|
|
|
|
dhcp-authoritative
|
2016-12-29 14:19:44 +00:00
|
|
|
dhcp-range=${DHCP_START},${DHCP_END},${leasetime}
|
2016-12-28 02:14:47 +00:00
|
|
|
dhcp-option=option:router,${DHCP_ROUTER}
|
|
|
|
dhcp-leasefile=/etc/pihole/dhcp.leases
|
2016-12-30 16:31:57 +00:00
|
|
|
#quiet-dhcp
|
2017-01-03 13:24:33 +00:00
|
|
|
" > "${dhcpconfig}"
|
2019-05-01 09:20:26 +00:00
|
|
|
chmod 644 "${dhcpconfig}"
|
2017-01-03 13:24:33 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${PIHOLE_DOMAIN}" != "none" ]]; then
|
|
|
|
echo "domain=${PIHOLE_DOMAIN}" >> "${dhcpconfig}"
|
|
|
|
fi
|
2017-01-18 11:22:03 +00:00
|
|
|
|
2018-11-26 19:01:41 +00:00
|
|
|
# Sourced from setupVars
|
|
|
|
# shellcheck disable=SC2154
|
2018-11-25 07:39:44 +00:00
|
|
|
if [[ "${DHCP_rapid_commit}" == "true" ]]; then
|
|
|
|
echo "dhcp-rapid-commit" >> "${dhcpconfig}"
|
|
|
|
fi
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
if [[ "${DHCP_IPv6}" == "true" ]]; then
|
2018-07-20 20:57:15 +00:00
|
|
|
echo "#quiet-dhcp6
|
2016-12-28 02:14:47 +00:00
|
|
|
#enable-ra
|
|
|
|
dhcp-option=option6:dns-server,[::]
|
2016-12-29 14:26:23 +00:00
|
|
|
dhcp-range=::100,::1ff,constructor:${interface},ra-names,slaac,${leasetime}
|
2016-12-28 20:02:48 +00:00
|
|
|
ra-param=*,0,0
|
2017-01-03 13:24:33 +00:00
|
|
|
" >> "${dhcpconfig}"
|
2017-05-14 01:11:44 +00:00
|
|
|
fi
|
2016-12-28 02:14:47 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
else
|
|
|
|
if [[ -f "${dhcpconfig}" ]]; then
|
|
|
|
rm "${dhcpconfig}" &> /dev/null
|
|
|
|
fi
|
|
|
|
fi
|
2016-12-12 12:15:07 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
EnableDHCP() {
|
2018-07-20 20:57:15 +00:00
|
|
|
change_setting "DHCP_ACTIVE" "true"
|
|
|
|
change_setting "DHCP_START" "${args[2]}"
|
|
|
|
change_setting "DHCP_END" "${args[3]}"
|
|
|
|
change_setting "DHCP_ROUTER" "${args[4]}"
|
|
|
|
change_setting "DHCP_LEASETIME" "${args[5]}"
|
|
|
|
change_setting "PIHOLE_DOMAIN" "${args[6]}"
|
|
|
|
change_setting "DHCP_IPv6" "${args[7]}"
|
2018-11-25 07:39:44 +00:00
|
|
|
change_setting "DHCP_rapid_commit" "${args[8]}"
|
2016-12-12 14:34:05 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
# Remove possible old setting from file
|
|
|
|
delete_dnsmasq_setting "dhcp-"
|
|
|
|
delete_dnsmasq_setting "quiet-dhcp"
|
2016-12-28 02:14:47 +00:00
|
|
|
|
2019-05-30 14:41:37 +00:00
|
|
|
# If a DHCP client claims that its name is "wpad", ignore that.
|
|
|
|
# This fixes a security hole. see CERT Vulnerability VU#598349
|
|
|
|
# We also ignore "localhost" as Windows behaves strangely if a
|
|
|
|
# device claims this host name
|
|
|
|
add_dnsmasq_setting "dhcp-name-match=set:hostname-ignore,wpad
|
|
|
|
dhcp-name-match=set:hostname-ignore,localhost
|
|
|
|
dhcp-ignore-names=tag:hostname-ignore"
|
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
ProcessDHCPSettings
|
2016-12-12 14:34:05 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
RestartDNS
|
2016-12-12 14:34:05 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
DisableDHCP() {
|
2018-07-20 20:57:15 +00:00
|
|
|
change_setting "DHCP_ACTIVE" "false"
|
2016-12-28 02:14:47 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
# Remove possible old setting from file
|
|
|
|
delete_dnsmasq_setting "dhcp-"
|
|
|
|
delete_dnsmasq_setting "quiet-dhcp"
|
2016-12-12 14:34:05 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
ProcessDHCPSettings
|
2016-12-12 14:34:05 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
RestartDNS
|
2016-12-12 14:34:05 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
SetWebUILayout() {
|
2018-07-20 20:57:15 +00:00
|
|
|
change_setting "WEBUIBOXEDLAYOUT" "${args[2]}"
|
2016-12-13 13:59:52 +00:00
|
|
|
}
|
|
|
|
|
2020-03-31 20:48:10 +00:00
|
|
|
CheckUrl(){
|
|
|
|
local regex
|
|
|
|
# Check for characters NOT allowed in URLs
|
|
|
|
regex="[^a-zA-Z0-9:/?&%=~._-]"
|
|
|
|
if [[ "${1}" =~ ${regex} ]]; then
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-03-31 18:35:52 +00:00
|
|
|
CustomizeAdLists() {
|
2019-04-28 19:39:06 +00:00
|
|
|
local address
|
|
|
|
address="${args[3]}"
|
2019-10-14 21:59:58 +00:00
|
|
|
local comment
|
|
|
|
comment="${args[4]}"
|
2018-07-20 20:57:15 +00:00
|
|
|
|
2020-03-31 20:48:10 +00:00
|
|
|
if CheckUrl "${address}"; then
|
|
|
|
if [[ "${args[2]}" == "enable" ]]; then
|
|
|
|
sqlite3 "${gravityDBfile}" "UPDATE adlist SET enabled = 1 WHERE address = '${address}'"
|
|
|
|
elif [[ "${args[2]}" == "disable" ]]; then
|
|
|
|
sqlite3 "${gravityDBfile}" "UPDATE adlist SET enabled = 0 WHERE address = '${address}'"
|
|
|
|
elif [[ "${args[2]}" == "add" ]]; then
|
|
|
|
sqlite3 "${gravityDBfile}" "INSERT OR IGNORE INTO adlist (address, comment) VALUES ('${address}', '${comment}')"
|
|
|
|
elif [[ "${args[2]}" == "del" ]]; then
|
|
|
|
sqlite3 "${gravityDBfile}" "DELETE FROM adlist WHERE address = '${address}'"
|
|
|
|
else
|
|
|
|
echo "Not permitted"
|
|
|
|
return 1
|
|
|
|
fi
|
2018-07-20 20:57:15 +00:00
|
|
|
else
|
2020-03-31 20:48:10 +00:00
|
|
|
echo "Invalid Url"
|
2018-07-20 20:57:15 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2017-03-31 18:35:52 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
SetPrivacyMode() {
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${args[2]}" == "true" ]]; then
|
|
|
|
change_setting "API_PRIVACY_MODE" "true"
|
|
|
|
else
|
|
|
|
change_setting "API_PRIVACY_MODE" "false"
|
|
|
|
fi
|
2016-12-27 20:27:11 +00:00
|
|
|
}
|
|
|
|
|
2016-12-15 17:55:40 +00:00
|
|
|
ResolutionSettings() {
|
2018-07-20 20:57:15 +00:00
|
|
|
typ="${args[2]}"
|
|
|
|
state="${args[3]}"
|
2016-12-15 17:55:40 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${typ}" == "forward" ]]; then
|
|
|
|
change_setting "API_GET_UPSTREAM_DNS_HOSTNAME" "${state}"
|
|
|
|
elif [[ "${typ}" == "clients" ]]; then
|
|
|
|
change_setting "API_GET_CLIENT_HOSTNAME" "${state}"
|
|
|
|
fi
|
2016-12-16 16:33:01 +00:00
|
|
|
}
|
|
|
|
|
2017-01-25 09:33:25 +00:00
|
|
|
AddDHCPStaticAddress() {
|
2018-07-20 20:57:15 +00:00
|
|
|
mac="${args[2]}"
|
|
|
|
ip="${args[3]}"
|
|
|
|
host="${args[4]}"
|
|
|
|
|
|
|
|
if [[ "${ip}" == "noip" ]]; then
|
|
|
|
# Static host name
|
|
|
|
echo "dhcp-host=${mac},${host}" >> "${dhcpstaticconfig}"
|
|
|
|
elif [[ "${host}" == "nohost" ]]; then
|
|
|
|
# Static IP
|
|
|
|
echo "dhcp-host=${mac},${ip}" >> "${dhcpstaticconfig}"
|
|
|
|
else
|
|
|
|
# Full info given
|
|
|
|
echo "dhcp-host=${mac},${ip},${host}" >> "${dhcpstaticconfig}"
|
|
|
|
fi
|
2017-01-25 09:33:25 +00:00
|
|
|
}
|
|
|
|
|
2017-01-25 09:35:03 +00:00
|
|
|
RemoveDHCPStaticAddress() {
|
2018-07-20 20:57:15 +00:00
|
|
|
mac="${args[2]}"
|
|
|
|
sed -i "/dhcp-host=${mac}.*/d" "${dhcpstaticconfig}"
|
2017-01-25 09:35:03 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
SetHostRecord() {
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${1}" == "-h" ]] || [[ "${1}" == "--help" ]]; then
|
|
|
|
echo "Usage: pihole -a hostrecord <domain> [IPv4-address],[IPv6-address]
|
2017-07-26 17:00:08 +00:00
|
|
|
Example: 'pihole -a hostrecord home.domain.com 192.168.1.1,2001:db8:a0b:12f0::1'
|
|
|
|
Add a name to the DNS associated to an IPv4/IPv6 address
|
|
|
|
|
|
|
|
Options:
|
|
|
|
\"\" Empty: Remove host record
|
|
|
|
-h, --help Show this help dialog"
|
2018-07-20 20:57:15 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
2017-07-26 17:00:08 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ -n "${args[3]}" ]]; then
|
|
|
|
change_setting "HOSTRECORD" "${args[2]},${args[3]}"
|
|
|
|
echo -e " ${TICK} Setting host record for ${args[2]} to ${args[3]}"
|
|
|
|
else
|
|
|
|
change_setting "HOSTRECORD" ""
|
|
|
|
echo -e " ${TICK} Removing host record"
|
|
|
|
fi
|
2017-02-22 13:43:07 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
ProcessDNSSettings
|
2017-02-22 13:43:07 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
# Restart dnsmasq to load new configuration
|
|
|
|
RestartDNS
|
2017-02-22 13:43:07 +00:00
|
|
|
}
|
|
|
|
|
2017-09-14 14:24:29 +00:00
|
|
|
SetAdminEmail() {
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${1}" == "-h" ]] || [[ "${1}" == "--help" ]]; then
|
|
|
|
echo "Usage: pihole -a email <address>
|
2017-09-14 14:24:29 +00:00
|
|
|
Example: 'pihole -a email admin@address.com'
|
|
|
|
Set an administrative contact address for the Block Page
|
|
|
|
|
|
|
|
Options:
|
|
|
|
\"\" Empty: Remove admin contact
|
|
|
|
-h, --help Show this help dialog"
|
2018-07-20 20:57:15 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
2017-09-14 14:24:29 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ -n "${args[2]}" ]]; then
|
2020-04-05 09:20:35 +00:00
|
|
|
|
|
|
|
# Sanitize email address in case of security issues
|
2020-04-05 11:29:45 +00:00
|
|
|
# Regex from https://stackoverflow.com/a/2138832/4065967
|
2020-04-05 11:28:33 +00:00
|
|
|
local regex
|
|
|
|
regex="^[a-z0-9!#\$%&'*+/=?^_\`{|}~-]+(\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]([a-z0-9-]*[a-z0-9])?\$"
|
2020-04-05 11:34:14 +00:00
|
|
|
if [[ ! "${args[2]}" =~ ${regex} ]]; then
|
2020-04-05 09:20:35 +00:00
|
|
|
echo -e " ${CROSS} Invalid email address"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
change_setting "ADMIN_EMAIL" "${args[2]}"
|
|
|
|
echo -e " ${TICK} Setting admin contact to ${args[2]}"
|
|
|
|
else
|
|
|
|
change_setting "ADMIN_EMAIL" ""
|
|
|
|
echo -e " ${TICK} Removing admin contact"
|
|
|
|
fi
|
2017-09-14 14:24:29 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
SetListeningMode() {
|
2018-07-20 20:57:15 +00:00
|
|
|
source "${setupVars}"
|
2017-07-07 01:44:40 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "$3" == "-h" ]] || [[ "$3" == "--help" ]]; then
|
|
|
|
echo "Usage: pihole -a -i [interface]
|
2017-05-14 01:11:44 +00:00
|
|
|
Example: 'pihole -a -i local'
|
|
|
|
Specify dnsmasq's network interface listening behavior
|
|
|
|
|
|
|
|
Interfaces:
|
|
|
|
local Listen on all interfaces, but only allow queries from
|
|
|
|
devices that are at most one hop away (local devices)
|
|
|
|
single Listen only on ${PIHOLE_INTERFACE} interface
|
|
|
|
all Listen on all interfaces, permit all origins"
|
2018-07-20 20:57:15 +00:00
|
|
|
exit 0
|
2017-05-14 01:11:44 +00:00
|
|
|
fi
|
2017-07-07 01:44:40 +00:00
|
|
|
|
2018-07-20 20:57:15 +00:00
|
|
|
if [[ "${args[2]}" == "all" ]]; then
|
2019-10-16 02:29:55 +00:00
|
|
|
echo -e " ${INFO} Listening on all interfaces, permitting all origins. Please use a firewall!"
|
2018-07-20 20:57:15 +00:00
|
|
|
change_setting "DNSMASQ_LISTENING" "all"
|
|
|
|
elif [[ "${args[2]}" == "local" ]]; then
|
2019-10-16 02:29:55 +00:00
|
|
|
echo -e " ${INFO} Listening on all interfaces, permitting origins from one hop away (LAN)"
|
2018-07-20 20:57:15 +00:00
|
|
|
change_setting "DNSMASQ_LISTENING" "local"
|
|
|
|
else
|
|
|
|
echo -e " ${INFO} Listening only on interface ${PIHOLE_INTERFACE}"
|
|
|
|
change_setting "DNSMASQ_LISTENING" "single"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Don't restart DNS server yet because other settings
|
|
|
|
# will be applied afterwards if "-web" is set
|
|
|
|
if [[ "${args[3]}" != "-web" ]]; then
|
|
|
|
ProcessDNSSettings
|
|
|
|
# Restart dnsmasq to load new configuration
|
|
|
|
RestartDNS
|
|
|
|
fi
|
2017-03-01 09:46:20 +00:00
|
|
|
}
|
|
|
|
|
2017-05-14 01:11:44 +00:00
|
|
|
Teleporter() {
|
2019-08-14 21:28:13 +00:00
|
|
|
local datetimestamp
|
2019-08-15 09:20:55 +00:00
|
|
|
datetimestamp=$(date "+%Y-%m-%d_%H-%M-%S")
|
2019-04-23 02:43:26 +00:00
|
|
|
php /var/www/html/admin/scripts/pi-hole/php/teleporter.php > "pi-hole-teleporter_${datetimestamp}.tar.gz"
|
2017-03-05 13:08:44 +00:00
|
|
|
}
|
|
|
|
|
2019-07-06 07:32:41 +00:00
|
|
|
checkDomain()
|
|
|
|
{
|
|
|
|
local domain validDomain
|
|
|
|
# Convert to lowercase
|
|
|
|
domain="${1,,}"
|
|
|
|
validDomain=$(grep -P "^((-|_)*[a-z\\d]((-|_)*[a-z\\d])*(-|_)*)(\\.(-|_)*([a-z\\d]((-|_)*[a-z\\d])*))*$" <<< "${domain}") # Valid chars check
|
|
|
|
validDomain=$(grep -P "^[^\\.]{1,63}(\\.[^\\.]{1,63})*$" <<< "${validDomain}") # Length of each label
|
|
|
|
echo "${validDomain}"
|
|
|
|
}
|
|
|
|
|
2018-08-10 16:22:55 +00:00
|
|
|
addAudit()
|
2017-06-27 08:53:24 +00:00
|
|
|
{
|
2018-08-10 16:22:55 +00:00
|
|
|
shift # skip "-a"
|
|
|
|
shift # skip "audit"
|
2019-07-06 07:32:41 +00:00
|
|
|
local domains validDomain
|
2019-07-07 19:21:56 +00:00
|
|
|
domains=""
|
2019-07-05 12:10:33 +00:00
|
|
|
for domain in "$@"
|
2018-08-10 16:22:55 +00:00
|
|
|
do
|
2019-07-09 09:41:44 +00:00
|
|
|
# Check domain to be added. Only continue if it is valid
|
2019-07-06 07:32:41 +00:00
|
|
|
validDomain="$(checkDomain "${domain}")"
|
|
|
|
if [[ -n "${validDomain}" ]]; then
|
2019-07-08 17:22:35 +00:00
|
|
|
# Put comma in between domains when there is
|
2019-07-07 19:21:56 +00:00
|
|
|
# more than one domains to be added
|
2019-07-08 17:22:35 +00:00
|
|
|
# SQL INSERT allows adding multiple rows at once using the format
|
|
|
|
## INSERT INTO table (domain) VALUES ('abc.de'),('fgh.ij'),('klm.no'),('pqr.st');
|
2019-07-07 19:21:56 +00:00
|
|
|
if [[ -n "${domains}" ]]; then
|
|
|
|
domains="${domains},"
|
|
|
|
fi
|
|
|
|
domains="${domains}('${domain}')"
|
2019-07-06 07:32:41 +00:00
|
|
|
fi
|
2018-08-10 16:22:55 +00:00
|
|
|
done
|
2019-07-09 09:41:44 +00:00
|
|
|
# Insert only the domain here. The date_added field will be
|
|
|
|
# filled with its default value (date_added = current timestamp)
|
2019-07-08 17:22:35 +00:00
|
|
|
sqlite3 "${gravityDBfile}" "INSERT INTO domain_audit (domain) VALUES ${domains};"
|
2018-08-10 16:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
clearAudit()
|
|
|
|
{
|
2019-07-08 17:22:35 +00:00
|
|
|
sqlite3 "${gravityDBfile}" "DELETE FROM domain_audit;"
|
2017-06-27 08:53:24 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 11:12:39 +00:00
|
|
|
SetPrivacyLevel() {
|
2018-08-20 21:36:16 +00:00
|
|
|
# Set privacy level. Minimum is 0, maximum is 4
|
|
|
|
if [ "${args[2]}" -ge 0 ] && [ "${args[2]}" -le 4 ]; then
|
2018-07-20 20:57:15 +00:00
|
|
|
changeFTLsetting "PRIVACYLEVEL" "${args[2]}"
|
|
|
|
fi
|
2018-04-04 11:12:39 +00:00
|
|
|
}
|
|
|
|
|
2019-10-27 00:07:08 +00:00
|
|
|
AddCustomDNSAddress() {
|
2019-11-26 23:27:57 +00:00
|
|
|
echo -e " ${TICK} Adding custom DNS entry..."
|
|
|
|
|
2019-10-27 00:07:08 +00:00
|
|
|
ip="${args[2]}"
|
|
|
|
host="${args[3]}"
|
|
|
|
echo "${ip} ${host}" >> "${dnscustomfile}"
|
2019-11-26 23:27:57 +00:00
|
|
|
|
|
|
|
# Restart dnsmasq to load new custom DNS entries
|
|
|
|
RestartDNS
|
2019-10-27 00:07:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RemoveCustomDNSAddress() {
|
2019-11-26 23:27:57 +00:00
|
|
|
echo -e " ${TICK} Removing custom DNS entry..."
|
|
|
|
|
2019-10-28 12:21:05 +00:00
|
|
|
ip="${args[2]}"
|
|
|
|
host="${args[3]}"
|
|
|
|
sed -i "/${ip} ${host}/d" "${dnscustomfile}"
|
2019-11-26 23:27:57 +00:00
|
|
|
|
|
|
|
# Restart dnsmasq to update removed custom DNS entries
|
|
|
|
RestartDNS
|
2019-10-27 00:07:08 +00:00
|
|
|
}
|
|
|
|
|
2016-12-28 16:25:14 +00:00
|
|
|
main() {
|
2018-07-20 20:57:15 +00:00
|
|
|
args=("$@")
|
|
|
|
|
|
|
|
case "${args[1]}" in
|
|
|
|
"-p" | "password" ) SetWebPassword;;
|
|
|
|
"-c" | "celsius" ) unit="C"; SetTemperatureUnit;;
|
|
|
|
"-f" | "fahrenheit" ) unit="F"; SetTemperatureUnit;;
|
|
|
|
"-k" | "kelvin" ) unit="K"; SetTemperatureUnit;;
|
|
|
|
"setdns" ) SetDNSServers;;
|
|
|
|
"setexcludedomains" ) SetExcludeDomains;;
|
|
|
|
"setexcludeclients" ) SetExcludeClients;;
|
|
|
|
"poweroff" ) Poweroff;;
|
|
|
|
"reboot" ) Reboot;;
|
|
|
|
"restartdns" ) RestartDNS;;
|
|
|
|
"setquerylog" ) SetQueryLogOptions;;
|
|
|
|
"enabledhcp" ) EnableDHCP;;
|
|
|
|
"disabledhcp" ) DisableDHCP;;
|
|
|
|
"layout" ) SetWebUILayout;;
|
|
|
|
"-h" | "--help" ) helpFunc;;
|
|
|
|
"privacymode" ) SetPrivacyMode;;
|
|
|
|
"resolve" ) ResolutionSettings;;
|
|
|
|
"addstaticdhcp" ) AddDHCPStaticAddress;;
|
|
|
|
"removestaticdhcp" ) RemoveDHCPStaticAddress;;
|
|
|
|
"-r" | "hostrecord" ) SetHostRecord "$3";;
|
|
|
|
"-e" | "email" ) SetAdminEmail "$3";;
|
|
|
|
"-i" | "interface" ) SetListeningMode "$@";;
|
|
|
|
"-t" | "teleporter" ) Teleporter;;
|
|
|
|
"adlist" ) CustomizeAdLists;;
|
2018-08-10 16:22:55 +00:00
|
|
|
"audit" ) addAudit "$@";;
|
|
|
|
"clearaudit" ) clearAudit;;
|
2018-07-20 20:57:15 +00:00
|
|
|
"-l" | "privacylevel" ) SetPrivacyLevel;;
|
2019-10-27 00:07:08 +00:00
|
|
|
"addcustomdns" ) AddCustomDNSAddress;;
|
|
|
|
"removecustomdns" ) RemoveCustomDNSAddress;;
|
2018-07-20 20:57:15 +00:00
|
|
|
* ) helpFunc;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
shift
|
|
|
|
|
|
|
|
if [[ $# = 0 ]]; then
|
|
|
|
helpFunc
|
|
|
|
fi
|
2016-12-28 16:25:14 +00:00
|
|
|
}
|