Decided to make upgrade script more manual. Leaves time for other dev

This commit is contained in:
deajan 2015-09-23 22:27:08 +02:00
parent 1e8216f2ba
commit 5bca46e3cf
2 changed files with 41 additions and 42 deletions

View File

@ -4,7 +4,7 @@ PROGRAM="Osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(L) 2013-2015 by Orsiris \"Ozy\" de Jong" AUTHOR="(L) 2013-2015 by Orsiris \"Ozy\" de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION=1.1-unstable PROGRAM_VERSION=1.1-unstable
PROGRAM_BUILD=2015092305 PROGRAM_BUILD=2015092306
## type doesn't work on platforms other than linux (bash). If if doesn't work, always assume output is not a zero exitcode ## type doesn't work on platforms other than linux (bash). If if doesn't work, always assume output is not a zero exitcode
if ! type -p "$BASH" > /dev/null; then if ! type -p "$BASH" > /dev/null; then
@ -1739,9 +1739,9 @@ function _SoftDeleteLocal {
if [ -d "$replica_deletion_path" ]; then if [ -d "$replica_deletion_path" ]; then
if [ $_DRYRUN -eq 1 ]; then if [ $_DRYRUN -eq 1 ]; then
Logger "Listing files older than $change_time days on [$replica_type] replica. Does not remove anything." "NOTICE" Logger "Listing files older than $change_time days on $replica_type replica. Does not remove anything." "NOTICE"
else else
Logger "Removing files older than $change_time days on [$replica_type] replica." "NOTICE" Logger "Removing files older than $change_time days on $replica_type replica." "NOTICE"
fi fi
if [ $_VERBOSE -eq 1 ]; then if [ $_VERBOSE -eq 1 ]; then
# Cannot launch log function from xargs, ugly hack # Cannot launch log function from xargs, ugly hack
@ -1758,13 +1758,13 @@ function _SoftDeleteLocal {
WaitForCompletion $! $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME $FUNCNAME WaitForCompletion $! $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME $FUNCNAME
retval=$? retval=$?
if [ $retval -ne 0 ]; then if [ $retval -ne 0 ]; then
Logger "Error while executing cleanup on [$replica_type] replica." "ERROR" Logger "Error while executing cleanup on $replica_type replica." "ERROR"
Logger "Command output:\n$(cat $RUN_DIR/osync.$FUNCNAME.$SCRIPT_PID)" "NOTICE" Logger "Command output:\n$(cat $RUN_DIR/osync.$FUNCNAME.$SCRIPT_PID)" "NOTICE"
else else
Logger "Cleanup complete on [$replica_type] replica." "NOTICE" Logger "Cleanup complete on $replica_type replica." "NOTICE"
fi fi
elif [ -d "$replica_deletion_path" ] && ! [ -w "$replica_deletion_path" ]; then elif [ -d "$replica_deletion_path" ] && ! [ -w "$replica_deletion_path" ]; then
Logger "Warning: [$replica_type] replica dir [$replica_deletion_path] is not writable. Cannot clean old files." "ERROR" Logger "Warning: $replica_type replica dir [$replica_deletion_path] is not writable. Cannot clean old files." "ERROR"
fi fi
} }

View File

@ -6,11 +6,13 @@ CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION="1.0x to v1.1" PROGRAM_VERSION="1.0x to v1.1"
PROGRAM_BUILD=2015091801 PROGRAM_BUILD=2015091801
TREE_CURRENT_FILENAME="-tree-current-$SYNC_ID" function Init {
TREE_AFTER_FILENAME="-tree-after-$SYNC_ID" TREE_CURRENT_FILENAME="-tree-current-$SYNC_ID"
TREE_AFTER_FILENAME_NO_SUFFIX="-tree-after-$SYNC_ID" TREE_AFTER_FILENAME="-tree-after-$SYNC_ID"
DELETED_LIST_FILENAME="-deleted-list-$SYNC_ID$" TREE_AFTER_FILENAME_NO_SUFFIX="-tree-after-$SYNC_ID"
FAILED_DELETE_LIST_FILENAME="-failed-delete-$SYNC_ID" DELETED_LIST_FILENAME="-deleted-list-$SYNC_ID$"
FAILED_DELETE_LIST_FILENAME="-failed-delete-$SYNC_ID"
}
function Usage { function Usage {
echo "DEV VERSION !!! DO NOT USE" echo "DEV VERSION !!! DO NOT USE"
@ -19,20 +21,18 @@ function Usage {
echo $AUTHOR echo $AUTHOR
echo $CONTACT echo $CONTACT
echo "" echo ""
echo "This script migrates osync v1.0x setups to v1.1 by updating config files and state directories" echo "This script migrates osync v1.0x setups to v1.1 by updating state filenames and config files."
echo "Usage: migrate.sh /path/to/config/directory" echo ""
echo "Usage: migrate.sh /path/to/config_file.conf"
echo "Usage: migrate.sh --replica=/path/to/replica --sync-id=someid"
echo ""
echo "This script must be run manually on all replicas. If slave replica is remote, must be run locally on slave system."
echo "If sync-id is not specified, it will assume handling a quicksync task."
echo "Config files must also be updated if they exist."
exit 1 exit 1
} }
if [ "$1" == "" ] || [ ! -d "$1" ] || [ ! -w "$1" ]; then
Usage;
else
CONF_DIR="$1"
# Make sure there is no ending slash
CONF_DIR="${CONF_DIR%/}"
fi
function RenameStateFiles { function RenameStateFiles {
local state_dir="${1}" # Absolute path to statedir local state_dir="${1}" # Absolute path to statedir
@ -71,25 +71,24 @@ function RewriteConfigFiles {
sed -i 's/SLAVE/TARGET/g' "$config_file" sed -i 's/SLAVE/TARGET/g' "$config_file"
} }
function ExtractInitiatorFromConfigFile { parameter="$1"
local config_file="${1}" second_param="$2"
#TODO: Extract initiator from config file if [ "${parameter:0,10}" == "--replica=" ]; then
echo "$initiator_path" if [ "${second_param:0,10}" == "--sync-id=" ]; then
} $SYNC_ID=${second_param##*=}
else
$SYNC_ID="quicksync task"
fi
Init
REPLICA_DIR=${i##*=}
RenameStateFiles "$REPLICA_DIR"
function ExtractTargetFromConfigFile { elif [ "$parameter" != "" ] && [ -d "$parameter" ] && [ -w "$parameter" ]; then
local config_file="${1}" CONF_DIR="$parameter"
# Make sure there is no ending slash
#TODO: Extract target from config file CONF_DIR="${CONF_DIR%/}"
echo "$target_path" RewriteConfigFiles "$CONF_DIR"
} else
Usage
for i in "$CONF_DIR/*.conf"; do fi
if [ "$i" != "$CONF_DIR/*.conf" ]; then
echo "Updating config file $i"
RewriteConfigFiles "$i"
echo "Updating master state dir for config $i"
RenameStateFilesLocal $(ExtractInitiatorFromConfigFile $i)
RenameStateFilesRemote $(ExtractTargetFromConfigFile $i)
done