2
0
mirror of https://github.com/deajan/osync synced 2024-11-03 15:40:14 +00:00

Upgrade script adds missing config file values

This commit is contained in:
deajan 2015-12-15 13:18:46 +01:00
parent 9fda36adb7
commit 03719ecb94
5 changed files with 37 additions and 20 deletions

View File

@ -15,6 +15,7 @@ RECENT CHANGES
--------------
! XX Dec 2015: osync v1.1 released
- Better upgrade script (adding missing new config values)
- More fixes for GNU / non-GNU versions of mail command
- Added bogus config file checks & environment checks
- Added delta copies disable option

View File

@ -7,7 +7,7 @@ PROGRAM_VERSION=1.1-pre
PROGRAM_BUILD=2015112805
IS_STABLE=no
FUNC_BUILD=2015121501
FUNC_BUILD=2015121502
## BEGIN Generic functions for osync & obackup written in 2013-2015 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
@ -280,7 +280,7 @@ function SendAlert {
if type mail > /dev/null 2>&1 ; then
if $(type -p mail) -V | grep "GNU" > /dev/null; then echo ok; fi
attachment_command="-A $ALERT_LOG_FILE"
elif ($type -p mail) -V; then
elif $(type -p mail) -V; then
attachment_command="-a $ALERT_LOG_FILE"
else
attachment_command=""

View File

@ -1,4 +1,4 @@
FUNC_BUILD=2015121501
FUNC_BUILD=2015121502
## BEGIN Generic functions for osync & obackup written in 2013-2015 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
@ -271,7 +271,7 @@ function SendAlert {
if type mail > /dev/null 2>&1 ; then
if $(type -p mail) -V | grep "GNU" > /dev/null; then echo ok; fi
attachment_command="-A $ALERT_LOG_FILE"
elif ($type -p mail) -V; then
elif $(type -p mail) -V; then
attachment_command="-a $ALERT_LOG_FILE"
else
attachment_command=""

View File

@ -7,7 +7,7 @@ PROGRAM_VERSION=1.1-pre
PROGRAM_BUILD=2015112805
IS_STABLE=no
FUNC_BUILD=2015121501
FUNC_BUILD=2015121502
## BEGIN Generic functions for osync & obackup written in 2013-2015 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
@ -268,7 +268,7 @@ function SendAlert {
if type mail > /dev/null 2>&1 ; then
if $(type -p mail) -V | grep "GNU" > /dev/null; then echo ok; fi
attachment_command="-A $ALERT_LOG_FILE"
elif ($type -p mail) -V; then
elif $(type -p mail) -V; then
attachment_command="-a $ALERT_LOG_FILE"
else
attachment_command=""

View File

@ -1,10 +1,12 @@
#!/bin/bash
#!/usr/bin/env bash
PROGRAM="Osync instance upagrade script" # Rsync based two way sync engine with fault tolerance
PROGRAM="osync instance upgrade script"
SUBPROGRAM="osync"
AUTHOR="(L) 2015 by Orsiris \"Ozy\" de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION="1.0x to v1.1"
PROGRAM_BUILD=2015092601
OLD_PROGRAM_VERSION="1.0x"
NEW_PROGRAM_VERSION="v1.1x"
PROGRAM_BUILD=2015121501
function Init {
OSYNC_DIR=".osync_workdir"
@ -51,15 +53,15 @@ function Init {
}
function Usage {
echo "$PROGRAM $PROGRAM_VERSION $PROGRAM_BUILD"
echo "$PROGRAM $PROGRAM_BUILD"
echo $AUTHOR
echo $CONTACT
echo ""
echo "This script migrates osync v1.0x setups to v1.1 by updating state filenames and config files."
echo "This script migrates osync $OLD_PROGRAM_VERSION setups to $NEW_PROGRAM_VERSION by updating state filenames and config files."
echo ""
echo "Usage: upgrade.sh /path/to/config_file.conf"
echo "Usage: upgrade.sh --master=/path/to/master/replica --slave=/path/to/local/slave/replica --sync-id=existing_id"
echo "Usage: upgrade.sh --master=/path/to/master/replica --slave=ssh://[backupuser]@remotehost.com[:portnumber]//path/to/slave/replica --sync-id=existing_id --rsakey=/path/to/rsa/key"
echo "Usage: $0 /path/to/config_file.conf"
echo "Usage: $0 --master=/path/to/master/replica --slave=/path/to/local/slave/replica --sync-id=existing_id"
echo "Usage: $0 --master=/path/to/master/replica --slave=ssh://[backupuser]@remotehost.com[:portnumber]//path/to/slave/replica --sync-id=existing_id --rsakey=/path/to/rsa/key"
echo ""
echo "If config file is provided, the config file itself and both replicas from config file will be updated."
echo "If no config file provided, assume you run the update script just like any other quicksync task."
@ -93,10 +95,10 @@ function LoadConfigFile {
echo "Wrong configuration file supplied [$config_file]. Sync cannot start."
exit 1
else
egrep '^#|^[^ ]*=[^;&]*' "$config_file" > "./osync.$FUNCNAME.$$"
egrep '^#|^[^ ]*=[^;&]*' "$config_file" > "./$SUBPROGRAM.$FUNCNAME.$$"
# Shellcheck source=./sync.conf
source "./osync.$FUNCNAME.$$"
rm -f "./osync.$FUNCNAME.$$"
source "./$SUBPROGRAM.$FUNCNAME.$$"
rm -f "./$SUBPROGRAM.$FUNCNAME.$$"
fi
}
@ -305,10 +307,17 @@ function RewriteConfigFiles {
local config_file="${1}"
if ! grep "MASTER_SYNC_DIR=" "$config_file" > /dev/null; then
echo "Config file $config_file does not seem like an osync v1.0x file."
exit
echo "Config file [$config_file] does not seem to be an osync v1.0x file."
exit 1
fi
echo "Backing up [$config_file] as [$config_file.save]"
cp --preserve "$config_file" "$config_file.save"
if [ $? != 0 ]; then
echo "Cannot backup config file."
exit 1
fi
echo "Rewriting config file $config_file"
#TODO: exclude occurences between doublequotes
@ -317,6 +326,13 @@ function RewriteConfigFiles {
sed -i 's/SLAVE_SYNC_DIR/TARGET_SYNC_DIR/g' "$config_file"
sed -i 's/CONFLICT_PREVALANCE=master/CONFLICT_PREVALANCE=initiator/g' "$config_file"
sed -i 's/CONFLICT_PREVALANCE=slave/CONFLICT_PREVALANCE=target/g' "$config_file"
sed -i 's/SYNC_ID=/INSTANCE_ID=/g' "$config_file"
# Add missing config file values
sed -i '/RSYNC_REMOTE_PATH=*/a RSYNC_PATTERN_FIRST=include' "$config_file"
sed -i '/RSYNC_PATTERN_FIRST=*/a RSYNC_INCLUDE_PATTERN=""' "$config_file"
sed -i '/RSYNC_EXCLUDE_FROM=*/a RSYNC_INCLUDE_FROM=""' "$config_file"
sed -i '/PARTIAL=*/a DELTA_COPIES=yes' "$config_file"
}
_QUICKSYNC=0