|
|
|
@ -71,7 +71,7 @@ function TrapStop {
|
|
|
|
|
function TrapQuit {
|
|
|
|
|
local exitcode
|
|
|
|
|
|
|
|
|
|
if [ $ERROR_ALERT -ne 0 ]; then
|
|
|
|
|
if [ $ERROR_ALERT == true ]; then
|
|
|
|
|
UnlockReplicas
|
|
|
|
|
if [ "$_DEBUG" != "yes" ]
|
|
|
|
|
then
|
|
|
|
@ -85,7 +85,7 @@ function TrapQuit {
|
|
|
|
|
CleanUp
|
|
|
|
|
Logger "$PROGRAM finished with errors." "ERROR"
|
|
|
|
|
exitcode=1
|
|
|
|
|
elif [ $WARN_ALERT -ne 0 ]; then
|
|
|
|
|
elif [ $WARN_ALERT == true ]; then
|
|
|
|
|
UnlockReplicas
|
|
|
|
|
if [ "$_DEBUG" != "yes" ]
|
|
|
|
|
then
|
|
|
|
@ -452,12 +452,12 @@ function CheckLocks {
|
|
|
|
|
|
|
|
|
|
local pids
|
|
|
|
|
|
|
|
|
|
if [ $_NOLOCKS -eq 1 ]; then
|
|
|
|
|
if [ $_NOLOCKS == true ]; then
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Do not bother checking for locks when FORCE_UNLOCK is set
|
|
|
|
|
if [ $FORCE_UNLOCK -eq 1 ]; then
|
|
|
|
|
if [ $FORCE_UNLOCK == true ]; then
|
|
|
|
|
WriteLockFiles
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
|
exit 1
|
|
|
|
@ -593,7 +593,7 @@ function UnlockReplicas {
|
|
|
|
|
|
|
|
|
|
local pids
|
|
|
|
|
|
|
|
|
|
if [ $_NOLOCKS -eq 1 ]; then
|
|
|
|
|
if [ $_NOLOCKS == true ]; then
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -706,6 +706,14 @@ function _get_file_ctime_mtime_local {
|
|
|
|
|
|
|
|
|
|
echo -n "" > "$RUN_DIR/$PROGRAM.ctime_mtime.$replica_type.$SCRIPT_PID"
|
|
|
|
|
while read -r file; do $STAT_CTIME_MTIME_CMD "$replica_path$file" | sort >> "$RUN_DIR/$PROGRAM.ctime_mtime.$replica_type.$SCRIPT_PID"; done < "$file_list"
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
|
Logger "Getting file attributes failed [$retval] on $replica_type. Stopping execution." "CRITICAL"
|
|
|
|
|
if [ $_VERBOSE == true ] && [ -f "$RUN_DIR/$PROGRAM.ctime_mtime.$replica_type.$SCRIPT_PID" ]; then
|
|
|
|
|
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.ctime_mtime.$replica_type.$SCRIPT_PID)" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _get_file_ctime_mtime_remote {
|
|
|
|
@ -721,7 +729,7 @@ function _get_file_ctime_mtime_remote {
|
|
|
|
|
eval "$cmd"
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
|
Logger "Getting file attributes failed [$retval] on $replica_type. Stopping execution." "CRITICAL"
|
|
|
|
|
if [ $_VERBOSE -eq 0 ] && [ -f "$RUN_DIR/$PROGRAM.ctime_mtime.$replica_type.$SCRIPT_PID" ]; then
|
|
|
|
|
if [ $_VERBOSE == true ] && [ -f "$RUN_DIR/$PROGRAM.ctime_mtime.$replica_type.$SCRIPT_PID" ]; then
|
|
|
|
|
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.ctime_mtime.$replica_type.$SCRIPT_PID)" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
exit 1
|
|
|
|
@ -752,13 +760,13 @@ function sync_attrs {
|
|
|
|
|
eval "$rsync_cmd"
|
|
|
|
|
WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME ${FUNCNAME[0]} false $KEEP_LOGGING
|
|
|
|
|
retval=$?
|
|
|
|
|
if [ $_VERBOSE -eq 1 ] && [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" ]; then
|
|
|
|
|
if [ $_VERBOSE == true ] && [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" ]; then
|
|
|
|
|
Logger "List:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $retval != 0 ] && [ $retval != 24 ]; then
|
|
|
|
|
Logger "Getting list of files that need updates failed [$retval]. Stopping execution." "CRITICAL"
|
|
|
|
|
if [ $_VERBOSE -eq 0 ] && [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" ]; then
|
|
|
|
|
if [ $_VERBOSE == false ] && [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" ]; then
|
|
|
|
|
Logger "Rsync output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
exit 1 #WIP: check why exit $retval was used
|
|
|
|
@ -832,13 +840,13 @@ function sync_attrs {
|
|
|
|
|
eval "$rsync_cmd"
|
|
|
|
|
WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME ${FUNCNAME[0]} false $KEEP_LOGGING
|
|
|
|
|
retval=$?
|
|
|
|
|
if [ $_VERBOSE -eq 1 ] && [ -f "$RUN_DIR/$PROGRAM.attr-update.$dest_replica.$SCRIPT_PID" ]; then
|
|
|
|
|
if [ $_VERBOSE == true ] && [ -f "$RUN_DIR/$PROGRAM.attr-update.$dest_replica.$SCRIPT_PID" ]; then
|
|
|
|
|
Logger "List:\n$(cat $RUN_DIR/$PROGRAM.attr-update.$dest_replica.$SCRIPT_PID)" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $retval != 0 ] && [ $retval != 24 ]; then
|
|
|
|
|
Logger "Updating file attributes on $dest_replica [$retval]. Stopping execution." "CRITICAL"
|
|
|
|
|
if [ $_VERBOSE -eq 0 ] && [ -f "$RUN_DIR/$PROGRAM.attr-update.$dest_replica.$SCRIPT_PID" ]; then
|
|
|
|
|
if [ $_VERBOSE == false ] && [ -f "$RUN_DIR/$PROGRAM.attr-update.$dest_replica.$SCRIPT_PID" ]; then
|
|
|
|
|
Logger "Rsync output:\n$(cat $RUN_DIR/$PROGRAM.attr-update.$dest_replica.$SCRIPT_PID)" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
exit 1 #WIP check why exit $retval was used
|
|
|
|
@ -886,13 +894,13 @@ function sync_update {
|
|
|
|
|
Logger "RSYNC_CMD: $rsync_cmd" "DEBUG"
|
|
|
|
|
eval "$rsync_cmd"
|
|
|
|
|
retval=$?
|
|
|
|
|
if [ $_VERBOSE -eq 1 ] && [ -f "$RUN_DIR/$PROGRAM.update.$destination_replica.$SCRIPT_PID" ]; then
|
|
|
|
|
if [ $_VERBOSE == true ] && [ -f "$RUN_DIR/$PROGRAM.update.$destination_replica.$SCRIPT_PID" ]; then
|
|
|
|
|
Logger "List:\n$(cat $RUN_DIR/$PROGRAM.update.$destination_replica.$SCRIPT_PID)" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $retval != 0 ] && [ $retval != 24 ]; then
|
|
|
|
|
Logger "Updating $destination_replica replica failed. Stopping execution." "CRITICAL"
|
|
|
|
|
if [ $_VERBOSE -eq 0 ] && [ -f "$RUN_DIR/$PROGRAM.update.$destination_replica.$SCRIPT_PID" ]; then
|
|
|
|
|
if [ $_VERBOSE == false ] && [ -f "$RUN_DIR/$PROGRAM.update.$destination_replica.$SCRIPT_PID" ]; then
|
|
|
|
|
Logger "Rsync output:\n$(cat $RUN_DIR/$PROGRAM.update.$destination_replica.$SCRIPT_PID)" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
exit 1 #WIP exit $retval
|
|
|
|
@ -913,7 +921,7 @@ function _delete_local {
|
|
|
|
|
local parentdir
|
|
|
|
|
local previous_file=""
|
|
|
|
|
|
|
|
|
|
if [ ! -d "$replica_dir$deletion_dir" ] && [ $_DRYRUN -ne 1 ]; then
|
|
|
|
|
if [ ! -d "$replica_dir$deletion_dir" ] && [ $_DRYRUN == false ]; then
|
|
|
|
|
$COMMAND_SUDO mkdir -p "$replica_dir$deletion_dir"
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
|
Logger "Cannot create local replica deletion directory in [$replica_dir$deletion_dir]." "ERROR"
|
|
|
|
@ -924,12 +932,12 @@ function _delete_local {
|
|
|
|
|
while read -r files; do
|
|
|
|
|
## On every run, check wheter the next item is already deleted because it is included in a directory already deleted
|
|
|
|
|
if [[ "$files" != "$previous_file/"* ]] && [ "$files" != "" ]; then
|
|
|
|
|
if [ $_VERBOSE -eq 1 ]; then
|
|
|
|
|
if [ $_VERBOSE == true ]; then
|
|
|
|
|
Logger "Soft deleting $replica_dir$files" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$SOFT_DELETE" != "no" ]; then
|
|
|
|
|
if [ $_DRYRUN -ne 1 ]; then
|
|
|
|
|
if [ $_DRYRUN == false ]; then
|
|
|
|
|
if [ -e "$replica_dir$deletion_dir/$files" ]; then
|
|
|
|
|
rm -rf "${replica_dir:?}$deletion_dir/$files"
|
|
|
|
|
Logger "Deleting file [$replica_dir$files]." "DEBUG"
|
|
|
|
@ -954,7 +962,7 @@ function _delete_local {
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
if [ $_DRYRUN -ne 1 ]; then
|
|
|
|
|
if [ $_DRYRUN == false ]; then
|
|
|
|
|
if [ -e "$replica_dir$files" ]; then
|
|
|
|
|
rm -rf "$replica_dir$files"
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
@ -1003,7 +1011,7 @@ $SSH_CMD ERROR_ALERT=0 sync_on_changes=$sync_on_changes _SILENT=$_SILENT _DEBUG=
|
|
|
|
|
local value="${1}" # What to log
|
|
|
|
|
echo -e "$value" >&2 #TODO(high): logfile output missing
|
|
|
|
|
|
|
|
|
|
if [ $_SILENT -eq 0 ]; then
|
|
|
|
|
if [ $_SILENT == false ]; then
|
|
|
|
|
echo -e "$value"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
@ -1040,7 +1048,7 @@ $SSH_CMD ERROR_ALERT=0 sync_on_changes=$sync_on_changes _SILENT=$_SILENT _DEBUG=
|
|
|
|
|
parentdir=
|
|
|
|
|
previous_file=""
|
|
|
|
|
|
|
|
|
|
if [ ! -d "$REPLICA_DIR$DELETE_DIR" ] && [ $_DRYRUN -ne 1 ]; then
|
|
|
|
|
if [ ! -d "$REPLICA_DIR$DELETE_DIR" ] && [ $_DRYRUN == false ]; then
|
|
|
|
|
$COMMAND_SUDO mkdir -p "$REPLICA_DIR$DELETE_DIR"
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
|
Logger "Cannot create remote replica deletion directory in [$REPLICA_DIR$DELETE_DIR]." "ERROR"
|
|
|
|
@ -1051,12 +1059,12 @@ $SSH_CMD ERROR_ALERT=0 sync_on_changes=$sync_on_changes _SILENT=$_SILENT _DEBUG=
|
|
|
|
|
while read -r files; do
|
|
|
|
|
## On every run, check wheter the next item is already deleted because it is included in a directory already deleted
|
|
|
|
|
if [[ "$files" != "$previous_file/"* ]] && [ "$files" != "" ]; then
|
|
|
|
|
if [ $_VERBOSE -eq 1 ]; then
|
|
|
|
|
if [ $_VERBOSE == true ]; then
|
|
|
|
|
Logger "Soft deleting $REPLICA_DIR$files" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$SOFT_DELETE" != "no" ]; then
|
|
|
|
|
if [ $_DRYRUN -ne 1 ]; then
|
|
|
|
|
if [ $_DRYRUN == false ]; then
|
|
|
|
|
if [ -e "$REPLICA_DIR$DELETE_DIR/$files" ]; then
|
|
|
|
|
$COMMAND_SUDO rm -rf "$REPLICA_DIR$DELETE_DIR/$files"
|
|
|
|
|
Logger "Deleting file [$REPLICA_DIR$files]." "DEBUG"
|
|
|
|
@ -1080,7 +1088,7 @@ $SSH_CMD ERROR_ALERT=0 sync_on_changes=$sync_on_changes _SILENT=$_SILENT _DEBUG=
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
if [ $_DRYRUN -ne 1 ]; then
|
|
|
|
|
if [ $_DRYRUN == false ]; then
|
|
|
|
|
if [ -e "$REPLICA_DIR$files" ]; then
|
|
|
|
|
$COMMAND_SUDO rm -rf "$REPLICA_DIR$files"
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
@ -1144,7 +1152,7 @@ function deletion_propagation {
|
|
|
|
|
fi
|
|
|
|
|
retval=$?
|
|
|
|
|
if [ $retval == 0 ]; then
|
|
|
|
|
if [ -f "$RUN_DIR/$PROGRAM._delete_remote.$SCRIPT_PID" ] && [ $_VERBOSE -eq 1 ]; then
|
|
|
|
|
if [ -f "$RUN_DIR/$PROGRAM._delete_remote.$SCRIPT_PID" ] && [ $_VERBOSE == true ]; then
|
|
|
|
|
Logger "Remote:\n$(cat $RUN_DIR/$PROGRAM._delete_remote.$SCRIPT_PID)" "DEBUG"
|
|
|
|
|
fi
|
|
|
|
|
return $retval
|
|
|
|
@ -1494,13 +1502,13 @@ function _SoftDeleteLocal {
|
|
|
|
|
local retval
|
|
|
|
|
|
|
|
|
|
if [ -d "$replica_deletion_path" ]; then
|
|
|
|
|
if [ $_DRYRUN -eq 1 ]; then
|
|
|
|
|
if [ $_DRYRUN == true ]; then
|
|
|
|
|
Logger "Listing files older than $change_time days on $replica_type replica. Does not remove anything." "NOTICE"
|
|
|
|
|
else
|
|
|
|
|
Logger "Removing files older than $change_time days on $replica_type replica." "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $_VERBOSE -eq 1 ]; then
|
|
|
|
|
if [ $_VERBOSE == true ]; then
|
|
|
|
|
# Cannot launch log function from xargs, ugly hack
|
|
|
|
|
$COMMAND_SUDO $FIND_CMD "$replica_deletion_path/" -type f -ctime +$change_time -print0 | xargs -0 -I {} echo "Will delete file {}" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID"
|
|
|
|
|
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "NOTICE"
|
|
|
|
@ -1508,7 +1516,7 @@ function _SoftDeleteLocal {
|
|
|
|
|
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $_DRYRUN -ne 1 ]; then
|
|
|
|
|
if [ $_DRYRUN == false ]; then
|
|
|
|
|
$COMMAND_SUDO $FIND_CMD "$replica_deletion_path/" -type f -ctime +$change_time -print0 | xargs -0 -I {} $COMMAND_SUDO rm -f "{}" && $COMMAND_SUDO $FIND_CMD "$replica_deletion_path/" -type d -empty -ctime +$change_time -print0 | xargs -0 -I {} $COMMAND_SUDO rm -rf "{}" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" 2>&1
|
|
|
|
|
else
|
|
|
|
|
Dummy
|
|
|
|
@ -1536,13 +1544,13 @@ function _SoftDeleteRemote {
|
|
|
|
|
CheckConnectivity3rdPartyHosts
|
|
|
|
|
CheckConnectivityRemoteHost
|
|
|
|
|
|
|
|
|
|
if [ $_DRYRUN -eq 1 ]; then
|
|
|
|
|
if [ $_DRYRUN == true ]; then
|
|
|
|
|
Logger "Listing files older than $change_time days on $replica_type replica. Does not remove anything." "NOTICE"
|
|
|
|
|
else
|
|
|
|
|
Logger "Removing files older than $change_time days on $replica_type replica." "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $_VERBOSE -eq 1 ]; then
|
|
|
|
|
if [ $_VERBOSE == true ]; then
|
|
|
|
|
# Cannot launch log function from xargs, ugly hack
|
|
|
|
|
cmd=$SSH_CMD' "if [ -d \"'$replica_deletion_path'\" ]; then '$COMMAND_SUDO' '$REMOTE_FIND_CMD' \"'$replica_deletion_path'/\" -type f -ctime +'$change_time' -print0 | xargs -0 -I {} echo Will delete file {} && '$COMMAND_SUDO' '$REMOTE_FIND_CMD' \"'$replica_deletion_path'/\" -type d -empty -ctime '$change_time' -print0 | xargs -0 -I {} echo Will delete directory {}; else echo \"No remote backup/deletion directory.\"; fi" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
|
|
|
|
Logger "cmd: $cmd" "DEBUG"
|
|
|
|
@ -1550,7 +1558,7 @@ function _SoftDeleteRemote {
|
|
|
|
|
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $_DRYRUN -ne 1 ]; then
|
|
|
|
|
if [ $_DRYRUN == false ]; then
|
|
|
|
|
cmd=$SSH_CMD' "if [ -d \"'$replica_deletion_path'\" ]; then '$COMMAND_SUDO' '$REMOTE_FIND_CMD' \"'$replica_deletion_path'/\" -type f -ctime +'$change_time' -print0 | xargs -0 -I {} '$COMMAND_SUDO' rm -f \"{}\" && '$COMMAND_SUDO' '$REMOTE_FIND_CMD' \"'$replica_deletion_path'/\" -type d -empty -ctime '$change_time' -print0 | xargs -0 -I {} '$COMMAND_SUDO' rm -rf \"{}\"; else echo \"No remote backup/deletion directory.\"; fi" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1'
|
|
|
|
|
|
|
|
|
|
Logger "cmd: $cmd" "DEBUG"
|
|
|
|
@ -1611,7 +1619,7 @@ function Init {
|
|
|
|
|
set -o errtrace
|
|
|
|
|
|
|
|
|
|
# Do not use exit and quit traps if osync runs in monitor mode
|
|
|
|
|
if [ $sync_on_changes -eq 0 ]; then
|
|
|
|
|
if [ $sync_on_changes == false ]; then
|
|
|
|
|
trap TrapStop INT HUP TERM QUIT
|
|
|
|
|
trap TrapQuit EXIT
|
|
|
|
|
else
|
|
|
|
@ -1681,7 +1689,7 @@ function Init {
|
|
|
|
|
local partial_dir="_partial"
|
|
|
|
|
local last_action="last-action"
|
|
|
|
|
local resume_count="resume-count"
|
|
|
|
|
if [ "$_DRYRUN" -eq 1 ]; then
|
|
|
|
|
if [ "$_DRYRUN" == true ]; then
|
|
|
|
|
local dry_suffix="-dry"
|
|
|
|
|
else
|
|
|
|
|
local dry_suffix=
|
|
|
|
@ -1725,11 +1733,11 @@ function Init {
|
|
|
|
|
## Set sync only function arguments for rsync
|
|
|
|
|
SYNC_OPTS="-u"
|
|
|
|
|
|
|
|
|
|
if [ $_VERBOSE -eq 1 ]; then
|
|
|
|
|
if [ $_VERBOSE == true ]; then
|
|
|
|
|
SYNC_OPTS=$SYNC_OPTS" -i"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $STATS -eq 1 ]; then
|
|
|
|
|
if [ $STATS == true ]; then
|
|
|
|
|
SYNC_OPTS=$SYNC_OPTS" --stats"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -1852,8 +1860,8 @@ function SyncOnChanges {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# quicksync mode settings, overriden by config file
|
|
|
|
|
STATS=0
|
|
|
|
|
PARTIAL=0
|
|
|
|
|
STATS=false
|
|
|
|
|
PARTIAL=no
|
|
|
|
|
if [ "$CONFLICT_PREVALANCE" == "" ]; then
|
|
|
|
|
CONFLICT_PREVALANCE=initiator
|
|
|
|
|
fi
|
|
|
|
@ -1861,14 +1869,17 @@ fi
|
|
|
|
|
INITIATOR_LOCK_FILE_EXISTS=false
|
|
|
|
|
TARGET_LOCK_FILE_EXISTS=false
|
|
|
|
|
|
|
|
|
|
FORCE_UNLOCK=0
|
|
|
|
|
no_maxtime=0
|
|
|
|
|
FORCE_UNLOCK=false
|
|
|
|
|
no_maxtime=false
|
|
|
|
|
opts=""
|
|
|
|
|
ERROR_ALERT=0
|
|
|
|
|
ERROR_ALERT=false
|
|
|
|
|
WARN_ALERT=false
|
|
|
|
|
# Number of CTRL+C
|
|
|
|
|
SOFT_STOP=0
|
|
|
|
|
# Number of given replicas in command line
|
|
|
|
|
_QUICK_SYNC=0
|
|
|
|
|
sync_on_changes=0
|
|
|
|
|
_NOLOCKS=0
|
|
|
|
|
sync_on_changes=false
|
|
|
|
|
_NOLOCKS=false
|
|
|
|
|
osync_cmd=$0
|
|
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]
|
|
|
|
@ -1880,7 +1891,7 @@ first=1
|
|
|
|
|
for i in "$@"; do
|
|
|
|
|
case $i in
|
|
|
|
|
--dry)
|
|
|
|
|
_DRYRUN=1
|
|
|
|
|
_DRYRUN=true
|
|
|
|
|
opts=$opts" --dry"
|
|
|
|
|
;;
|
|
|
|
|
--silent)
|
|
|
|
@ -1888,11 +1899,11 @@ for i in "$@"; do
|
|
|
|
|
opts=$opts" --silent"
|
|
|
|
|
;;
|
|
|
|
|
--verbose)
|
|
|
|
|
_VERBOSE=1
|
|
|
|
|
_VERBOSE=true
|
|
|
|
|
opts=$opts" --verbose"
|
|
|
|
|
;;
|
|
|
|
|
--stats)
|
|
|
|
|
STATS=1
|
|
|
|
|
STATS=true
|
|
|
|
|
opts=$opts" --stats"
|
|
|
|
|
;;
|
|
|
|
|
--partial)
|
|
|
|
@ -1900,11 +1911,11 @@ for i in "$@"; do
|
|
|
|
|
opts=$opts" --partial"
|
|
|
|
|
;;
|
|
|
|
|
--force-unlock)
|
|
|
|
|
FORCE_UNLOCK=1
|
|
|
|
|
FORCE_UNLOCK=true
|
|
|
|
|
opts=$opts" --force-unlock"
|
|
|
|
|
;;
|
|
|
|
|
--no-maxtime)
|
|
|
|
|
no_maxtime=1
|
|
|
|
|
no_maxtime=true
|
|
|
|
|
opts=$opts" --no-maxtime"
|
|
|
|
|
;;
|
|
|
|
|
--help|-h|--version|-v)
|
|
|
|
@ -1912,15 +1923,15 @@ for i in "$@"; do
|
|
|
|
|
;;
|
|
|
|
|
--initiator=*)
|
|
|
|
|
_QUICK_SYNC=$(($_QUICK_SYNC + 1))
|
|
|
|
|
no_maxtime=1
|
|
|
|
|
INITIATOR_SYNC_DIR=${i##*=}
|
|
|
|
|
opts=$opts" --initiator=\"$INITIATOR_SYNC_DIR\""
|
|
|
|
|
no_maxtime=true
|
|
|
|
|
;;
|
|
|
|
|
--target=*)
|
|
|
|
|
_QUICK_SYNC=$(($_QUICK_SYNC + 1))
|
|
|
|
|
TARGET_SYNC_DIR=${i##*=}
|
|
|
|
|
opts=$opts" --target=\"$TARGET_SYNC_DIR\""
|
|
|
|
|
no_maxtime=1
|
|
|
|
|
no_maxtime=true
|
|
|
|
|
;;
|
|
|
|
|
--rsakey=*)
|
|
|
|
|
SSH_RSA_PRIVATE_KEY=${i##*=}
|
|
|
|
@ -1931,13 +1942,13 @@ for i in "$@"; do
|
|
|
|
|
opts=$opts" --instance-id=\"$INSTANCE_ID\""
|
|
|
|
|
;;
|
|
|
|
|
--on-changes)
|
|
|
|
|
sync_on_changes=1
|
|
|
|
|
_NOLOCKS=1
|
|
|
|
|
sync_on_changes=true
|
|
|
|
|
_NOLOCKS=true
|
|
|
|
|
_LOGGER_PREFIX="date"
|
|
|
|
|
_LOGGER_STDERR=1
|
|
|
|
|
_LOGGER_STDERR=true
|
|
|
|
|
;;
|
|
|
|
|
--no-locks)
|
|
|
|
|
_NOLOCKS=1
|
|
|
|
|
_NOLOCKS=true
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
if [ $first == "0" ]; then
|
|
|
|
@ -2026,13 +2037,13 @@ opts="${opts# *}"
|
|
|
|
|
Logger "-------------------------------------------------------------" "NOTICE"
|
|
|
|
|
Logger "Sync task [$INSTANCE_ID] launched as $LOCAL_USER@$LOCAL_HOST (PID $SCRIPT_PID)" "NOTICE"
|
|
|
|
|
|
|
|
|
|
if [ $sync_on_changes -eq 1 ]; then
|
|
|
|
|
if [ $sync_on_changes == true ]; then
|
|
|
|
|
SyncOnChanges
|
|
|
|
|
else
|
|
|
|
|
GetRemoteOS
|
|
|
|
|
InitRemoteOSSettings
|
|
|
|
|
|
|
|
|
|
if [ $no_maxtime -eq 1 ]; then
|
|
|
|
|
if [ $no_maxtime == true ]; then
|
|
|
|
|
SOFT_MAX_EXEC_TIME=0
|
|
|
|
|
HARD_MAX_EXEC_TIME=0
|
|
|
|
|
fi
|
|
|
|
|