Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/pihole
diff options
context:
space:
mode:
authorAdam Warner <me@adamwarner.co.uk>2022-01-31 02:05:28 +0300
committerAdam Warner <me@adamwarner.co.uk>2022-01-31 02:05:28 +0300
commit77e5121d438f7895ae6c512222802a0307c63ebb (patch)
tree5bf14b9bd34b2acb1865b79b47ae489d218f5b8b /pihole
parent1dd9d55d82501a7b05fc86eb621a2fc9a610c8b8 (diff)
Split new function out into a separte utility script and add a test for it. Can be used in future to organise re/commonly-used code
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
Diffstat (limited to 'pihole')
-rwxr-xr-xpihole21
1 files changed, 7 insertions, 14 deletions
diff --git a/pihole b/pihole
index 610c9f31..56d47eca 100755
--- a/pihole
+++ b/pihole
@@ -21,6 +21,9 @@ readonly FTL_PID_FILE="/run/pihole-FTL.pid"
readonly colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
source "${colfile}"
+readonly utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
+source "${utilsfile}"
+
webpageFunc() {
source "${PI_HOLE_SCRIPT_DIR}/webpage.sh"
main "$@"
@@ -170,16 +173,6 @@ restartDNS() {
fi
}
-addOrEditKeyValPair() {
- local key="${1}"
- local value="${2}"
- if grep -q "^${key}=" "${setupVars}"; then
- sed -i "/^${key}=/c\\${key}=${value}" "${setupVars}"
- else
- echo "${key}=${value}" >> "${setupVars}"
- fi
-}
-
piholeEnable() {
if [[ "${2}" == "-h" ]] || [[ "${2}" == "--help" ]]; then
echo "Usage: pihole disable [time]
@@ -233,7 +226,7 @@ Time:
fi
local str="Pi-hole Disabled"
- addOrEditKeyValPair "BLOCKING_ENABLED" "false"
+ addOrEditKeyValPair "BLOCKING_ENABLED" "false" "${setupVars}"
fi
else
# Enable Pi-hole
@@ -245,7 +238,7 @@ Time:
echo -e " ${INFO} Enabling blocking"
local str="Pi-hole Enabled"
- addOrEditKeyValPair "BLOCKING_ENABLED" "true"
+ addOrEditKeyValPair "BLOCKING_ENABLED" "true" "${setupVars}"
fi
restartDNS reload-lists
@@ -268,7 +261,7 @@ Options:
elif [[ "${1}" == "off" ]]; then
# Disable logging
sed -i 's/^log-queries/#log-queries/' /etc/dnsmasq.d/01-pihole.conf
- addOrEditKeyValPair "QUERY_LOGGING" "false"
+ addOrEditKeyValPair "QUERY_LOGGING" "false" "${setupVars}"
if [[ "${2}" != "noflush" ]]; then
# Flush logs
"${PI_HOLE_BIN_DIR}"/pihole -f
@@ -278,7 +271,7 @@ Options:
elif [[ "${1}" == "on" ]]; then
# Enable logging
sed -i 's/^#log-queries/log-queries/' /etc/dnsmasq.d/01-pihole.conf
- addOrEditKeyValPair "QUERY_LOGGING" "true"
+ addOrEditKeyValPair "QUERY_LOGGING" "true" "${setupVars}"
echo -e " ${INFO} Enabling logging..."
local str="Logging has been enabled!"
else