Compare commits
1 Commits
4125bcccdc
...
v6.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a393dd83f3 |
@@ -50,10 +50,9 @@ rm -f "/etc/pihole/GitHubVersions"
|
||||
rm -f "/etc/pihole/localbranches"
|
||||
rm -f "/etc/pihole/localversions"
|
||||
|
||||
# Create new versions file if it does not exist
|
||||
VERSION_FILE="/etc/pihole/versions"
|
||||
|
||||
# Truncates the file to zero length if it exists to clear it up, otherwise creates an empty file.
|
||||
truncate -s 0 "${VERSION_FILE}"
|
||||
touch "${VERSION_FILE}"
|
||||
chmod 644 "${VERSION_FILE}"
|
||||
|
||||
# if /pihole.docker.tag file exists, we will use it's value later in this script
|
||||
|
||||
@@ -30,6 +30,9 @@ addOrEditKeyValPair() {
|
||||
local key="${2}"
|
||||
local value="${3}"
|
||||
|
||||
# touch file to prevent grep error if file does not exist yet
|
||||
touch "${file}"
|
||||
|
||||
if grep -q "^${key}=" "${file}"; then
|
||||
# Key already exists in file, modify the value
|
||||
sed -i "/^${key}=/c\\${key}=${value}" "${file}"
|
||||
|
||||
@@ -2,7 +2,6 @@ def test_key_val_replacement_works(host):
|
||||
"""Confirms addOrEditKeyValPair either adds or replaces a key value pair in a given file"""
|
||||
host.run("""
|
||||
source /opt/pihole/utils.sh
|
||||
touch ./testoutput
|
||||
addOrEditKeyValPair "./testoutput" "KEY_ONE" "value1"
|
||||
addOrEditKeyValPair "./testoutput" "KEY_TWO" "value2"
|
||||
addOrEditKeyValPair "./testoutput" "KEY_ONE" "value3"
|
||||
|
||||
Reference in New Issue
Block a user