From 1b8c07332f23fbd06a8ecebccb61c1f9ab859f67 Mon Sep 17 00:00:00 2001 From: deajan Date: Tue, 21 May 2019 14:09:30 +0200 Subject: [PATCH] Fix for very old config files --- upgrade-v1.0x-v1.3x.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/upgrade-v1.0x-v1.3x.sh b/upgrade-v1.0x-v1.3x.sh index 1fca690..292b947 100755 --- a/upgrade-v1.0x-v1.3x.sh +++ b/upgrade-v1.0x-v1.3x.sh @@ -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 }