Fix for very old config files

pull/167/head
deajan 5 years ago
parent d17ece7e2c
commit 1b8c07332f

@ -7,7 +7,7 @@ CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
OLD_PROGRAM_VERSION="v1.0x-v1.2x"
NEW_PROGRAM_VERSION="v1.3x"
CONFIG_FILE_REVISION=1.3.0
PROGRAM_BUILD=2019052103
PROGRAM_BUILD=2019052104
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
if ! type "$BASH" > /dev/null; then
@ -555,9 +555,13 @@ function UpdateConfigHeader {
local config_file="${1}"
if ! grep "^CONFIG_FILE_REVISION=" > /dev/null "$config_file"; then
if grep "\[GENERAL\]" > /dev/null "$config_file"; then
sed -i'.tmp' '/^\[GENERAL\]$/a\'$'\n'CONFIG_FILE_REVISION=$CONFIG_FILE_REVISION$'\n''' "$config_file"
else
sed -i'.tmp' '/.*onfig file rev.*/a\'$'\n'CONFIG_FILE_REVISION=$CONFIG_FILE_REVISION$'\n''' "$config_file"
fi
# "onfig file rev" to deal with earlier variants of the file where c was lower or uppercase
sed -i'.tmp' 's/.*onfig file rev.*//' "$config_file"
sed -i'.tmp' '/^\[GENERAL\]$/a\'$'\n'CONFIG_FILE_REVISION=$CONFIG_FILE_REVISION$'\n''' "$config_file"
rm -f "$config_file.tmp"
fi
}

Loading…
Cancel
Save