Address review comments

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
pull/4653/head
Adam Warner 2 years ago
parent 7fa8cdd03e
commit 4d31d5ee11
No known key found for this signature in database
GPG Key ID: 872950F3ECF2B173

@ -56,11 +56,11 @@ addOrEditKeyValPair() {
# Deletes a key from target file
#
# Example usage:
# removeKey "PIHOLE_DNS_1" "/etc/pihole/setupVars.conf"
# removeKey "/etc/pihole/setupVars.conf" "PIHOLE_DNS_1"
#######################
removeKey() {
local key="${1}"
local file="${2}"
local file="${1}"
local key="${2}"
sed -i "/^${key}/d" "${file}"
}

@ -60,7 +60,7 @@ add_setting() {
}
delete_setting() {
removeKey "${1}" "${setupVars}"
removeKey "${setupVars}" "${1}"
}
change_setting() {
@ -72,7 +72,7 @@ addFTLsetting() {
}
deleteFTLsetting() {
removeKey "${1}" "${FTLconf}"
removeKey "${FTLconf}" "${1}"
}
changeFTLsetting() {
@ -84,7 +84,7 @@ add_dnsmasq_setting() {
}
delete_dnsmasq_setting() {
removeKey "${1}" "${dnsmasqconfig}"
removeKey "${dnsmasqconfig}" "${1}"
}
SetTemperatureUnit() {

@ -260,7 +260,7 @@ Options:
exit 0
elif [[ "${1}" == "off" ]]; then
# Disable logging
sed -i 's/^log-queries/#log-queries/' /etc/dnsmasq.d/01-pihole.conf
addOrEditKeyValPair /etc/dnsmasq.d/01-pihole.conf "log-queries"
addOrEditKeyValPair "${setupVars}" "QUERY_LOGGING" "false"
if [[ "${2}" != "noflush" ]]; then
# Flush logs
@ -270,7 +270,7 @@ Options:
local str="Logging has been disabled!"
elif [[ "${1}" == "on" ]]; then
# Enable logging
sed -i 's/^#log-queries/log-queries/' /etc/dnsmasq.d/01-pihole.conf
removeKey /etc/dnsmasq.d/01-pihole.conf "log-queries"
addOrEditKeyValPair "${setupVars}" "QUERY_LOGGING" "true"
echo -e " ${INFO} Enabling logging..."
local str="Logging has been enabled!"

@ -17,13 +17,13 @@ def test_key_val_replacement_works(host):
def test_key_val_removal_works(host):
''' Confirms addOrEditKeyValPair provides the expected output '''
''' Confirms removeKey provides the expected output '''
host.run('''
source /opt/pihole/utils.sh
addOrEditKeyValPair "./testoutput" "KEY_ONE" "value1"
addOrEditKeyValPair "./testoutput" "KEY_TWO" "value2"
addOrEditKeyValPair "./testoutput" "KEY_THREE" "value3"
removeKey "KEY_TWO" "./testoutput"
removeKey "./testoutput" "KEY_TWO"
''')
output = host.run('''
cat ./testoutput

Loading…
Cancel
Save