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