mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 14:58:08 +00:00
Revert "Ignore commented lines when reading PRIVACYLEVEL from config file" (#5223)
This commit is contained in:
commit
edbaf6d697
@ -44,7 +44,7 @@ addOrEditKeyValPair() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Takes two arguments: file and key.
|
# Takes two arguments: file, and key.
|
||||||
# Adds a key to target file
|
# Adds a key to target file
|
||||||
#
|
#
|
||||||
# Example usage:
|
# Example usage:
|
||||||
@ -68,7 +68,7 @@ addKey(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Takes two arguments: file and key.
|
# Takes two arguments: file, and key.
|
||||||
# Deletes a key or key/value pair from target file
|
# Deletes a key or key/value pair from target file
|
||||||
#
|
#
|
||||||
# Example usage:
|
# Example usage:
|
||||||
@ -80,24 +80,6 @@ removeKey() {
|
|||||||
sed -i "/^${key}/d" "${file}"
|
sed -i "/^${key}/d" "${file}"
|
||||||
}
|
}
|
||||||
|
|
||||||
#######################
|
|
||||||
# Takes two arguments: file and key.
|
|
||||||
# Returns the value of a given key from target file
|
|
||||||
# - ignores all commented lines
|
|
||||||
# - only returns the first value if multiple identical keys exist
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Example usage:
|
|
||||||
# getVal "/etc/pihole/setupVars.conf" "PIHOLE_DNS_1"
|
|
||||||
#######################
|
|
||||||
getVal() {
|
|
||||||
local file="${1}"
|
|
||||||
local key="${2}"
|
|
||||||
local value
|
|
||||||
value=$(sed -e '/^[[:blank:]]*#/d' "${file}" | grep "${key}" | awk -F "=" 'NR==1{printf$2}')
|
|
||||||
printf "%s" "$value"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# returns FTL's current telnet API port based on the setting in /etc/pihole-FTL.conf
|
# returns FTL's current telnet API port based on the setting in /etc/pihole-FTL.conf
|
||||||
|
@ -2612,8 +2612,7 @@ main() {
|
|||||||
|
|
||||||
# Get the privacy level if it exists (default is 0)
|
# Get the privacy level if it exists (default is 0)
|
||||||
if [[ -f "${FTL_CONFIG_FILE}" ]]; then
|
if [[ -f "${FTL_CONFIG_FILE}" ]]; then
|
||||||
# use getVal from utils.sh to get PRIVACYLEVEL
|
PRIVACY_LEVEL=$(sed -ne 's/PRIVACYLEVEL=\(.*\)/\1/p' "${FTL_CONFIG_FILE}")
|
||||||
PRIVACY_LEVEL=$(getVal "${FTL_CONFIG_FILE}" "PRIVACYLEVEL")
|
|
||||||
|
|
||||||
# If no setting was found, default to 0
|
# If no setting was found, default to 0
|
||||||
PRIVACY_LEVEL="${PRIVACY_LEVEL:-0}"
|
PRIVACY_LEVEL="${PRIVACY_LEVEL:-0}"
|
||||||
|
@ -82,22 +82,6 @@ def test_key_removal_works(host):
|
|||||||
assert expected_stdout == output.stdout
|
assert expected_stdout == output.stdout
|
||||||
|
|
||||||
|
|
||||||
def test_get_value_works(host):
|
|
||||||
"""Confirms getVal returns the correct value for a given key"""
|
|
||||||
output = host.run(
|
|
||||||
"""
|
|
||||||
source /opt/pihole/utils.sh
|
|
||||||
echo "Somekey=xxx" >> /tmp/testfile
|
|
||||||
echo "#Testkey=1234" >> /tmp/testfile
|
|
||||||
echo "Testkey=5678" >> /tmp/testfile
|
|
||||||
echo "Testkey=abcd" >> /tmp/testfile
|
|
||||||
getVal "/tmp/testfile" "Testkey"
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
expected_stdout = "5678"
|
|
||||||
assert expected_stdout == output.stdout
|
|
||||||
|
|
||||||
|
|
||||||
def test_getFTLAPIPort_default(host):
|
def test_getFTLAPIPort_default(host):
|
||||||
"""Confirms getFTLAPIPort returns the default API port"""
|
"""Confirms getFTLAPIPort returns the default API port"""
|
||||||
output = host.run(
|
output = host.run(
|
||||||
|
Loading…
Reference in New Issue
Block a user