From e1a081a7f1cd0327ec17f54d5237569ebf8d94a3 Mon Sep 17 00:00:00 2001 From: deajan Date: Tue, 21 May 2019 12:51:29 +0200 Subject: [PATCH] Fixed backup before upgrading --- upgrade-v1.0x-v1.3x.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/upgrade-v1.0x-v1.3x.sh b/upgrade-v1.0x-v1.3x.sh index d1c8da8..4838f75 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=2019052101 +PROGRAM_BUILD=2019052102 ## 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 @@ -459,7 +459,7 @@ function RenameStateFiles { fi } -function RewriteOldConfigFiles { +function CheckAndBackup { local config_file="${1}" if ! grep "MASTER_SYNC_DIR=" "$config_file" > /dev/null && ! grep "INITIATOR_SYNC_DIR=" "$config_file" > /dev/null; then @@ -473,6 +473,10 @@ function RewriteOldConfigFiles { echo "Cannot backup config file." exit 1 fi +} + +function RewriteOldConfigFiles { + local config_file="${1}" echo "Rewriting config file $config_file" @@ -591,6 +595,7 @@ elif [ "$1" != "" ] && [ -f "$1" ] && [ -w "$1" ]; then CONF_FILE="${CONF_FILE%/}" LoadConfigFile "$CONF_FILE" Init + CheckAndBackup "$CONF_FILE" RewriteSections "$CONF_FILE" RewriteOldConfigFiles "$CONF_FILE" AddMissingConfigOptionsAndFixBooleans "$CONF_FILE"