Minor enhancements

This commit is contained in:
deajan 2015-09-26 13:43:25 +02:00
parent 8a088d92cc
commit f4116ba69c
1 changed files with 85 additions and 71 deletions

View File

@ -4,7 +4,7 @@ PROGRAM="Osync instance upagrade script" # Rsync based two way sync engine with
AUTHOR="(L) 2015 by Orsiris \"Ozy\" de Jong" AUTHOR="(L) 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.0x to v1.1" PROGRAM_VERSION="1.0x to v1.1"
PROGRAM_BUILD=2015092501 PROGRAM_BUILD=2015092601
function Init { function Init {
OSYNC_DIR=".osync_workdir" OSYNC_DIR=".osync_workdir"
@ -93,9 +93,10 @@ function LoadConfigFile {
echo "Wrong configuration file supplied [$config_file]. Sync cannot start." echo "Wrong configuration file supplied [$config_file]. Sync cannot start."
exit 1 exit 1
else else
egrep '^#|^[^ ]*=[^;&]*' "$config_file" > "./osync.$FUNCNAME.$SCRIPT_PID" egrep '^#|^[^ ]*=[^;&]*' "$config_file" > "./osync.$FUNCNAME.$$"
# Shellcheck source=./sync.conf # Shellcheck source=./sync.conf
source "./osync.$FUNCNAME.$SCRIPT_PID" source "./osync.$FUNCNAME.$$"
rm -f "./osync.$FUNCNAME.$$"
fi fi
} }
@ -240,16 +241,23 @@ function _RenameStateFilesLocal {
rewrite=true rewrite=true
fi fi
fi fi
if [ $rewrite == true ]; then
echo "State dir rewritten."
else
echo "Nothing rewritten in state dir."
fi
} }
function _RenameStateFilesRemote { function _RenameStateFilesRemote {
echo "Connecting remotely to rewrite state files in [$1]." echo "Connecting remotely to rewrite state files in [$1]."
$SSH_CMD state_dir="${1}" DELETED_LIST_FILENAME="$DELETED_LIST_FILENAME" FAILED_DELETE_LIST_FILENAME="$FAILED_DELETE_LIST_FILENAME" 'bash -x -s' << 'ENDSSH' $SSH_CMD state_dir="${1}" DELETED_LIST_FILENAME="$DELETED_LIST_FILENAME" FAILED_DELETE_LIST_FILENAME="$FAILED_DELETE_LIST_FILENAME" 'bash -s' << 'ENDSSH'
# Make sure there is no ending slash # Make sure there is no ending slash
state_dir="${state_dir%/}/" state_dir="${state_dir%/}/"
rewrite=false
if [ -f "$state_dir""master"$DELETED_LIST_FILENAME ]; then if [ -f "$state_dir""master"$DELETED_LIST_FILENAME ]; then
mv -f "$state_dir""master"$DELETED_LIST_FILENAME "$state_dir""initiator"$DELETED_LIST_FILENAME mv -f "$state_dir""master"$DELETED_LIST_FILENAME "$state_dir""initiator"$DELETED_LIST_FILENAME
@ -275,6 +283,12 @@ $SSH_CMD state_dir="${1}" DELETED_LIST_FILENAME="$DELETED_LIST_FILENAME" FAILED_
rewrite=true rewrite=true
fi fi
fi fi
if [ $rewrite == true ]; then
echo "State dir rewritten."
else
echo "Nothing rewritten in state dir."
fi
ENDSSH ENDSSH
} }