More debug functionnality

pull/36/head
deajan 9 years ago
parent 78814c11bc
commit 4f799bf2e7

@ -6,7 +6,7 @@ KNOWN ISSUES
RECENT CHANGES RECENT CHANGES
-------------- --------------
- Added (much) more verbose debugging - Added (much) more verbose debugging (and possibility to remove debug code to gain speed)
- Force tree function to overwrite earlier tree files - Force tree function to overwrite earlier tree files
! Check existing dirs before checking for state dirs ! Check existing dirs before checking for state dirs
! Add Logger DEBUG to all eval statements ! Add Logger DEBUG to all eval statements

@ -35,6 +35,12 @@ Whenever there is some idea to postpone, use #TODO:dev-name: some remark
A marker must be left where on the line a dev is working (when the work isn't finished). Marker is #WIP:dev-name: some remark A marker must be left where on the line a dev is working (when the work isn't finished). Marker is #WIP:dev-name: some remark
dev-name is mandatory if more than one person is coding dev-name is mandatory if more than one person is coding
++++ Pre-processor comments
As debug / production environments cannot be set with bash, debug code can be removed easily by:
- Removing all lines containting comment #__WITH_PARANOIA_DEBUG
- Removing everying between comment #__BEGIN_WITH_PARANOIA_DEBUG and #__END_WITH_PARANOIRA_DEBUG
++++ Variables ++++ Variables
All local variables are lowercase, separated by _ (ex: low_wait) All local variables are lowercase, separated by _ (ex: low_wait)

@ -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=2015091206 PROGRAM_BUILD=2015091207
## 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
@ -20,11 +20,11 @@ else
SLEEP_TIME=1 SLEEP_TIME=1
fi fi
## allow function call checks ## allow function call checks #__WITH_PARANOIA_DEBUG
if [ "$_PARANOIA_DEBUG" == "yes" ];then if [ "$_PARANOIA_DEBUG" == "yes" ];then #__WITH_PARANOIA_DEBUG
_DEBUG=yes _DEBUG=yes #__WITH_PARANOIA_DEBUG
SLEEP_TIME=1 SLEEP_TIME=1 #__WITH_PARANOIA_DEBUG
fi fi #__WITH_PARANOIA_DEBUG
SCRIPT_PID=$$ SCRIPT_PID=$$
@ -201,12 +201,16 @@ function EscapeSpaces {
} }
function CleanUp { function CleanUp {
__CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ "$_DEBUG" != "yes" ]; then if [ "$_DEBUG" != "yes" ]; then
rm -f "$RUN_DIR/osync_*_$SCRIPT_PID" rm -f "$RUN_DIR/osync_*_$SCRIPT_PID"
fi fi
} }
function SendAlert { function SendAlert {
__CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ "$quick_sync" == "2" ]; then if [ "$quick_sync" == "2" ]; then
Logger "Current task is a quicksync task. Will not send any alert." "NOTICE" Logger "Current task is a quicksync task. Will not send any alert." "NOTICE"
return 0 return 0
@ -259,6 +263,8 @@ function SendAlert {
} }
function LoadConfigFile { function LoadConfigFile {
__CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
local config_file="${1}" local config_file="${1}"
if [ ! -f "$config_file" ]; then if [ ! -f "$config_file" ]; then
@ -274,6 +280,8 @@ function LoadConfigFile {
} }
function CheckEnvironment { function CheckEnvironment {
__CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_SYNC" == "yes" ]; then if [ "$REMOTE_SYNC" == "yes" ]; then
if ! type -p ssh > /dev/null 2>&1 if ! type -p ssh > /dev/null 2>&1
then then
@ -290,7 +298,8 @@ function CheckEnvironment {
} }
function GetLocalOS { function GetLocalOS {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
local local_os_var=$(uname -spio 2>&1) local local_os_var=$(uname -spio 2>&1)
if [ $? != 0 ]; then if [ $? != 0 ]; then
local local_os_var=$(uname -v 2>&1) local local_os_var=$(uname -v 2>&1)
@ -321,24 +330,24 @@ function GetLocalOS {
} }
function GetRemoteOS { function GetRemoteOS {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_SYNC" == "yes" ]; then if [ "$REMOTE_SYNC" == "yes" ]; then
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
eval "$SSH_CMD \"uname -spio\" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1" & eval "$SSH_CMD \"uname -spio\" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1" &
child_pid=$! child_pid=$!
WaitForTaskCompletion $child_pid 120 240 WaitForTaskCompletion $child_pid 120 240 $FUNCNAME_1
retval=$? retval=$?
if [ $retval != 0 ]; then if [ $retval != 0 ]; then
eval "$SSH_CMD \"uname -v\" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1" & eval "$SSH_CMD \"uname -v\" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1" &
child_pid=$! child_pid=$!
WaitForTaskCompletion $child_pid 120 240 WaitForTaskCompletion $child_pid 120 240 $FUNCNAME_2
retval=$? retval=$?
if [ $retval != 0 ]; then if [ $retval != 0 ]; then
eval "$SSH_CMD \"uname\" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1" & eval "$SSH_CMD \"uname\" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1" &
child_pid=$! child_pid=$!
WaitForTaskCompletion $child_pid 120 240 WaitForTaskCompletion $child_pid 120 240 $FUNCNAME_3
retval=$? retval=$?
if [ $retval != 0 ]; then if [ $retval != 0 ]; then
Logger "Cannot Get remote OS type." "ERROR" Logger "Cannot Get remote OS type." "ERROR"
@ -379,7 +388,9 @@ function WaitForTaskCompletion {
local pid="${1}" # pid to wait for local pid="${1}" # pid to wait for
local soft_max_time="${2}" # If program with pid $pid takes longer than $soft_max_time seconds, will log a warning, unless $soft_max_time equals 0. local soft_max_time="${2}" # If program with pid $pid takes longer than $soft_max_time seconds, will log a warning, unless $soft_max_time equals 0.
local hard_max_time="${3}" # If program with pid $pid takes longer than $hard_max_time seconds, will stop execution, unless $hard_max_time equals 0. local hard_max_time="${3}" # If program with pid $pid takes longer than $hard_max_time seconds, will stop execution, unless $hard_max_time equals 0.
__CheckArguments 3 $# $FUNCNAME "$*" local caller_name="${4}" # Who called this function
Logger "$FUNCNAME called by [$caller_name]." "DEBUG" #__WITH_PARANOIA_DEBUG
__CheckArguments 4 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
local soft_alert=0 # Does a soft alert need to be triggered local soft_alert=0 # Does a soft alert need to be triggered
local log_ttime=0 # local time instance for comparaison local log_ttime=0 # local time instance for comparaison
@ -420,14 +431,18 @@ function WaitForTaskCompletion {
sleep $SLEEP_TIME sleep $SLEEP_TIME
done done
wait $pid wait $pid
return $? local retval=$?
Logger "$FUNCNAME ended for [$caller_name]." "DEBUG" #__WITH_PARANOIA_DEBUG
return $retval
} }
function WaitForCompletion { function WaitForCompletion {
local pid="${1}" # pid to wait for local pid="${1}" # pid to wait for
local soft_max_time="${2}" # If program with pid $pid takes longer than $soft_max_time seconds, will log a warning, unless $soft_max_time equals 0. local soft_max_time="${2}" # If program with pid $pid takes longer than $soft_max_time seconds, will log a warning, unless $soft_max_time equals 0.
local hard_max_time="${3}" # If program with pid $pid takes longer than $hard_max_time seconds, will stop execution, unless $hard_max_time equals 0. local hard_max_time="${3}" # If program with pid $pid takes longer than $hard_max_time seconds, will stop execution, unless $hard_max_time equals 0.
__CheckArguments 3 $# $FUNCNAME "$*" local caller_name="${4}" # Who called this function
Logger "$FUNCNAME called by [$caller_name]" "DEBUG" #__WITH_PARANOIA_DEBUG
__CheckArguments 4 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
local soft_alert=0 # Does a soft alert need to be triggered local soft_alert=0 # Does a soft alert need to be triggered
local log_ttime=0 # local time instance for comparaison local log_ttime=0 # local time instance for comparaison
@ -467,13 +482,15 @@ function WaitForCompletion {
sleep $SLEEP_TIME sleep $SLEEP_TIME
done done
wait $pid wait $pid
return $? retval=$?
Logger "$FUNCNAME ended for [$caller_name]." "DEBUG" #__WITH_PARANOIA_DEBUG
return $retval
} }
function RunLocalCommand { function RunLocalCommand {
local command="${1}" # Command to run local command="${1}" # Command to run
local hard_max_time="${2}" # Max time to wait for command to compleet local hard_max_time="${2}" # Max time to wait for command to compleet
__CheckArguments 2 $# $FUNCNAME "$*" __CheckArguments 2 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ $_DRYRUN -ne 0 ]; then if [ $_DRYRUN -ne 0 ]; then
Logger "Dryrun: Local command [$command] not run." "NOTICE" Logger "Dryrun: Local command [$command] not run." "NOTICE"
@ -482,7 +499,7 @@ function RunLocalCommand {
Logger "Running command [$command] on local host." "NOTICE" Logger "Running command [$command] on local host." "NOTICE"
eval "$command" > $RUN_DIR/osync_run_local_$SCRIPT_PID 2>&1 & eval "$command" > $RUN_DIR/osync_run_local_$SCRIPT_PID 2>&1 &
child_pid=$! child_pid=$!
WaitForTaskCompletion $child_pid 0 $hard_max_time WaitForTaskCompletion $child_pid 0 $hard_max_time $FUNCNAME
retval=$? retval=$?
if [ $retval -eq 0 ]; then if [ $retval -eq 0 ]; then
Logger "Command succeded." "NOTICE" Logger "Command succeded." "NOTICE"
@ -504,7 +521,7 @@ function RunLocalCommand {
function RunRemoteCommand { function RunRemoteCommand {
local command="${1}" # Command to run local command="${1}" # Command to run
local hard_max_time="${2}" # Max time to wait for command to compleet local hard_max_time="${2}" # Max time to wait for command to compleet
__CheckArguments 2 $# $FUNCNAME "$*" __CheckArguments 2 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
@ -515,7 +532,7 @@ function RunRemoteCommand {
Logger "Running command [$command] on remote host." "NOTICE" Logger "Running command [$command] on remote host." "NOTICE"
eval "$SSH_CMD \"$command\" > $RUN_DIR/osync_run_remote_$SCRIPT_PID 2>&1 &" eval "$SSH_CMD \"$command\" > $RUN_DIR/osync_run_remote_$SCRIPT_PID 2>&1 &"
child_pid=$! child_pid=$!
WaitForTaskCompletion $child_pid 0 $hard_max_time WaitForTaskCompletion $child_pid 0 $hard_max_time $FUNCNAME
retval=$? retval=$?
if [ $retval -eq 0 ]; then if [ $retval -eq 0 ]; then
Logger "Command succeded." "NOTICE" Logger "Command succeded." "NOTICE"
@ -535,6 +552,8 @@ function RunRemoteCommand {
} }
function RunBeforeHook { function RunBeforeHook {
__CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ "$LOCAL_RUN_BEFORE_CMD" != "" ]; then if [ "$LOCAL_RUN_BEFORE_CMD" != "" ]; then
RunLocalCommand "$LOCAL_RUN_BEFORE_CMD" $MAX_EXEC_TIME_PER_CMD_BEFORE RunLocalCommand "$LOCAL_RUN_BEFORE_CMD" $MAX_EXEC_TIME_PER_CMD_BEFORE
fi fi
@ -545,6 +564,8 @@ function RunBeforeHook {
} }
function RunAfterHook { function RunAfterHook {
__CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ "$LOCAL_RUN_AFTER_CMD" != "" ]; then if [ "$LOCAL_RUN_AFTER_CMD" != "" ]; then
RunLocalCommand "$LOCAL_RUN_AFTER_CMD" $MAX_EXEC_TIME_PER_CMD_AFTER RunLocalCommand "$LOCAL_RUN_AFTER_CMD" $MAX_EXEC_TIME_PER_CMD_AFTER
fi fi
@ -555,7 +576,7 @@ function RunAfterHook {
} }
function CheckConnectivityRemoteHost { function CheckConnectivityRemoteHost {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_HOST_PING" != "no" ] && [ "$REMOTE_SYNC" != "no" ]; then if [ "$REMOTE_HOST_PING" != "no" ] && [ "$REMOTE_SYNC" != "no" ]; then
eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1"
@ -567,7 +588,7 @@ function CheckConnectivityRemoteHost {
} }
function CheckConnectivity3rdPartyHosts { function CheckConnectivity3rdPartyHosts {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_3RD_PARTY_HOSTS" != "" ]; then if [ "$REMOTE_3RD_PARTY_HOSTS" != "" ]; then
remote_3rd_party_success=0 remote_3rd_party_success=0
@ -590,9 +611,9 @@ function CheckConnectivity3rdPartyHosts {
fi fi
} }
#__BEGIN_WITH_PARANOIA_DEBUG
function __CheckArguments { function __CheckArguments {
# Checks the number of arguments and raises an error if some are missing # Checks the number of arguments and raises an error if some are missing
if [ "$_DEBUG" == "yes" ]; then if [ "$_DEBUG" == "yes" ]; then
local number_of_arguments="${1}" # Number of arguments a function should have local number_of_arguments="${1}" # Number of arguments a function should have
@ -622,6 +643,7 @@ function __CheckArguments {
fi fi
} }
#__END_WITH_PARANOIA_DEBUG
###### realpath.sh implementation from https://github.com/mkropat/sh-realpath ###### realpath.sh implementation from https://github.com/mkropat/sh-realpath
@ -739,7 +761,7 @@ _bsd_stat_readlink() {
function _CreateStateDirsLocal { function _CreateStateDirsLocal {
local replica_state_dir="${1}" local replica_state_dir="${1}"
__CheckArguments 1 $# $FUNCNAME "$*" __CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if ! [ -d "$replica_state_dir" ]; then if ! [ -d "$replica_state_dir" ]; then
$COMMAND_SUDO mkdir -p "$replica_state_dir" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1 $COMMAND_SUDO mkdir -p "$replica_state_dir" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1
@ -753,14 +775,14 @@ function _CreateStateDirsLocal {
function _CreateStateDirsRemote { function _CreateStateDirsRemote {
local replica_state_dir="${1}" local replica_state_dir="${1}"
__CheckArguments 1 $# $FUNCNAME "$*" __CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
$cmd = "$SSH_CMD \"if ! [ -d \\\"$replica_state_dir\\\" ]; then $COMMAND_SUDO mkdir -p \\\"$replica_state_dir\\\"; fi 2>&1\" &" $cmd = "$SSH_CMD \"if ! [ -d \\\"$replica_state_dir\\\" ]; then $COMMAND_SUDO mkdir -p \\\"$replica_state_dir\\\"; fi 2>&1\" &"
eval $cmd > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1 eval $cmd > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1
WaitForTaskCompletion $! 0 1800 WaitForTaskCompletion $! 0 1800 $FUNCNAME
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot create remote state dir [$replica_state_dir]." "CRITICAL" Logger "Cannot create remote state dir [$replica_state_dir]." "CRITICAL"
Logger "Command output:\n$RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID" "ERROR" Logger "Command output:\n$RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID" "ERROR"
@ -769,7 +791,7 @@ function _CreateStateDirsRemote {
} }
function CreateStateDirs { function CreateStateDirs {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
_CreateStateDirsLocal "$INITIATOR_STATE_DIR" _CreateStateDirsLocal "$INITIATOR_STATE_DIR"
if [ "$REMOTE_SYNC" == "no" ]; then if [ "$REMOTE_SYNC" == "no" ]; then
@ -781,7 +803,7 @@ function CreateStateDirs {
function _CheckReplicaPathsLocal { function _CheckReplicaPathsLocal {
local replica_path="${1}" local replica_path="${1}"
__CheckArguments 1 $# $FUNCNAME "$*" __CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ ! -d "$replica_path" ]; then if [ ! -d "$replica_path" ]; then
if [ "$CREATE_DIRS" == "yes" ]; then if [ "$CREATE_DIRS" == "yes" ]; then
@ -807,14 +829,14 @@ function _CheckReplicaPathsLocal {
function _CheckReplicaPathsRemote { function _CheckReplicaPathsRemote {
local replica_path="${1}" local replica_path="${1}"
__CheckArguments 1 $# $FUNCNAME "$*" __CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
cmd="$SSH_CMD \"if ! [ -d \\\"$replica_path\\\" ]; then if [ "$CREATE_DIRS" == "yes" ]; then $COMMAND_SUDO mkdir -p \\\"$replica_path\\\"; fi; fi 2>&1\" &" cmd="$SSH_CMD \"if ! [ -d \\\"$replica_path\\\" ]; then if [ "$CREATE_DIRS" == "yes" ]; then $COMMAND_SUDO mkdir -p \\\"$replica_path\\\"; fi; fi 2>&1\" &"
eval $cmd > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1 eval $cmd > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1
WaitForTaskCompletion $! 0 1800 WaitForTaskCompletion $! 0 1800 $FUNCNAME
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot create remote replica path [$replica_path]." "CRITICAL" Logger "Cannot create remote replica path [$replica_path]." "CRITICAL"
Logger "Command output:\n$RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID" "ERROR" Logger "Command output:\n$RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID" "ERROR"
@ -823,7 +845,7 @@ function _CheckReplicaPathsRemote {
cmd="$SSH_CMD \"if [ ! -w "$replica_path" ];then exit 1; fi 2>&1\" &" cmd="$SSH_CMD \"if [ ! -w "$replica_path" ];then exit 1; fi 2>&1\" &"
eval $cmd eval $cmd
WaitForTaskCompletion $! 0 1800 WaitForTaskCompletion $! 0 1800 $FUNCNAME
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Remote replica path [$replica_path] is not writable." "CRITICAL" Logger "Remote replica path [$replica_path] is not writable." "CRITICAL"
exit 1 exit 1
@ -831,7 +853,7 @@ function _CheckReplicaPathsRemote {
} }
function CheckReplicaPaths { function CheckReplicaPaths {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
#INITIATOR_SYNC_DIR_CANN=$(realpath "$INITIATOR_SYNC_DIR") #TODO: investigate realpath & readlink issues on MSYS and busybox here #INITIATOR_SYNC_DIR_CANN=$(realpath "$INITIATOR_SYNC_DIR") #TODO: investigate realpath & readlink issues on MSYS and busybox here
#TARGET_SYNC_DIR_CANN=$(realpath "$TARGET_SYNC_DIR") #TARGET_SYNC_DIR_CANN=$(realpath "$TARGET_SYNC_DIR")
@ -843,7 +865,7 @@ function CheckReplicaPaths {
# fi # fi
#fi #fi
_CheckReplicaPathsLocal "$INITIATOR_SYNC_DIR" _CheckReplicaPathsLocal "$INITIATOR_SYNC_DIR"
if [ "$REMOTE_SYNC" == "no" ]; then if [ "$REMOTE_SYNC" == "no" ]; then
_CheckReplicaPathsLocal "$TARGET_SYNC_DIR" _CheckReplicaPathsLocal "$TARGET_SYNC_DIR"
else else
@ -853,7 +875,7 @@ function CheckReplicaPaths {
function _CheckDiskSpaceLocal { function _CheckDiskSpaceLocal {
local replica_path="${1}" local replica_path="${1}"
__CheckArguments 1 $# $FUNCNAME "$*" __CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
Logger "Checking minimum disk space in [$replica_path]." "NOTICE" Logger "Checking minimum disk space in [$replica_path]." "NOTICE"
@ -865,7 +887,7 @@ function _CheckDiskSpaceLocal {
function _CheckDiskSpaceRemote { function _CheckDiskSpaceRemote {
local replica_path="${1}" local replica_path="${1}"
__CheckArguments 1 $# $FUNCNAME "$*" __CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
Logger "Checking minimum disk space on target [$replica_path]." "NOTICE" Logger "Checking minimum disk space on target [$replica_path]." "NOTICE"
@ -874,7 +896,7 @@ function _CheckDiskSpaceRemote {
cmd="$SSH_CMD \"$COMMAND_SUDO df -P \\\"$replica_path\\\"\" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1 &" cmd="$SSH_CMD \"$COMMAND_SUDO df -P \\\"$replica_path\\\"\" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID 2>&1 &"
eval $cmd eval $cmd
WaitForTaskCompletion $! 0 1800 WaitForTaskCompletion $! 0 1800 $FUNCNAME
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Cannot get free space on target [$replica_path]." "ERROR" Logger "Cannot get free space on target [$replica_path]." "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"
@ -887,7 +909,7 @@ function _CheckDiskSpaceRemote {
} }
function CheckDiskSpace { function CheckDiskSpace {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
_CheckDiskSpaceLocal "$INITIATOR_SYNC_DIR" _CheckDiskSpaceLocal "$INITIATOR_SYNC_DIR"
if [ "$REMOTE_SYNC" == "no" ]; then if [ "$REMOTE_SYNC" == "no" ]; then
@ -898,7 +920,7 @@ function CheckDiskSpace {
} }
function RsyncExcludePattern { function RsyncExcludePattern {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
# Disable globbing so wildcards from exclusions don't get expanded # Disable globbing so wildcards from exclusions don't get expanded
set -f set -f
@ -925,7 +947,7 @@ function RsyncExcludePattern {
} }
function RsyncExcludeFrom { function RsyncExcludeFrom {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ ! "$RSYNC_EXCLUDE_FROM" == "" ]; then if [ ! "$RSYNC_EXCLUDE_FROM" == "" ]; then
## Check if the exclude list has a full path, and if not, add the config file path if there is one ## Check if the exclude list has a full path, and if not, add the config file path if there is one
@ -941,7 +963,7 @@ function RsyncExcludeFrom {
function _WriteLockFilesLocal { function _WriteLockFilesLocal {
local lockfile="${1}" local lockfile="${1}"
__CheckArguments 1 $# $FUNCNAME "$*" __CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
$COMMAND_SUDO echo "$SCRIPT_PID@$SYNC_ID" > "$lockfile" #TODO: Determine best format for lockfile for v2 $COMMAND_SUDO echo "$SCRIPT_PID@$SYNC_ID" > "$lockfile" #TODO: Determine best format for lockfile for v2
if [ $? != 0 ]; then if [ $? != 0 ]; then
@ -954,14 +976,14 @@ function _WriteLockFilesLocal {
function _WriteLockFilesRemote { function _WriteLockFilesRemote {
local lockfile="${1}" local lockfile="${1}"
__CheckArguments 1 $# $FUNCNAME "$*" __CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
cmd="$SSH_CMD \"echo $SCRIPT_PID@$SYNC_ID | $COMMAND_SUDO tee \\\"$lock_file\\\" > /dev/null \"" & cmd="$SSH_CMD \"echo $SCRIPT_PID@$SYNC_ID | $COMMAND_SUDO tee \\\"$lock_file\\\" > /dev/null \"" &
eval $cmd eval $cmd
WaitForTaskCompletion $? 0 1800 WaitForTaskCompletion $? 0 1800 $FUNCNAME
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Could not set lock on remote target replica." "CRITICAL" Logger "Could not set lock on remote target replica." "CRITICAL"
exit 1 exit 1
@ -971,7 +993,7 @@ function _WriteLockFilesRemote {
} }
function WriteLockFiles { function WriteLockFiles {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
_WriteLockFilesLocal "$INITIATOR_LOCKFILE" _WriteLockFilesLocal "$INITIATOR_LOCKFILE"
if [ "$REMOTE_SYNC" != "yes" ]; then if [ "$REMOTE_SYNC" != "yes" ]; then
@ -983,7 +1005,7 @@ function WriteLockFiles {
function _CheckLocksLocal { function _CheckLocksLocal {
local lockfile="${1}" local lockfile="${1}"
__CheckArguments 1 $# $FUNCNAME "$*" __CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ -f "$lockfile" ]; then if [ -f "$lockfile" ]; then
local lockfile_content=$(cat $lockfile) local lockfile_content=$(cat $lockfile)
@ -1002,14 +1024,14 @@ function _CheckLocksLocal {
function _CheckLocksRemote { #TODO: Rewrite this a bit more beautiful function _CheckLocksRemote { #TODO: Rewrite this a bit more beautiful
local lockfile="${1}" local lockfile="${1}"
__CheckArguments 1 $# $FUNCNAME "$*" __CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
cmd="$SSH_CMD \"if [ -f \\\"$lockfile\\\" ]; then cat \\\"$lockfile\\\"; fi\" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID" & cmd="$SSH_CMD \"if [ -f \\\"$lockfile\\\" ]; then cat \\\"$lockfile\\\"; fi\" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID" &
eval $cmd eval $cmd
WaitForTaskCompletion $? 0 1800 WaitForTaskCompletion $? 0 1800 $FUNCNAME
if [ $? != 0 ]; then if [ $? != 0 ]; then
if [ -f $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID ]; then if [ -f $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID ]; then
local lockfile_content=$(cat $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID) local lockfile_content=$(cat $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID)
@ -1047,7 +1069,7 @@ function _CheckLocksRemote { #TODO: Rewrite this a bit more beautiful
} }
function CheckLocks { function CheckLocks {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ $_NOLOCKS -eq 1 ]; then if [ $_NOLOCKS -eq 1 ]; then
return 0 return 0
@ -1072,7 +1094,7 @@ function CheckLocks {
function _UnlockReplicasLocal { function _UnlockReplicasLocal {
local lockfile="${1}" local lockfile="${1}"
__CheckArguments 1 $# $FUNCNAME "$*" __CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ -f "$lockfile" ]; then if [ -f "$lockfile" ]; then
$COMMAND_SUDO rm "$lockfile" $COMMAND_SUDO rm "$lockfile"
@ -1086,14 +1108,14 @@ function _UnlockReplicasLocal {
function _UnlockReplicasRemote { function _UnlockReplicasRemote {
local lockfile="${1}" local lockfile="${1}"
__CheckArguments 1 $# $FUNCNAME "$*" __CheckArguments 1 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
cmd="$SSH_CMD \"if [ -f \\\"$localfile\\\" ]; then $COMMAND_SUDO rm \\\"$lockfile\\\"; fi 2>&1\"" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID & cmd="$SSH_CMD \"if [ -f \\\"$localfile\\\" ]; then $COMMAND_SUDO rm \\\"$lockfile\\\"; fi 2>&1\"" > $RUN_DIR/osync_$FUNCNAME_$SCRIPT_PID &
eval $cmd eval $cmd
WaitForTaskCompletion $? 0 1800 WaitForTaskCompletion $? 0 1800 $FUNCNAME
if [ $? != 0 ]; then if [ $? != 0 ]; then
Logger "Could not unlock remote replica." "ERROR" Logger "Could not unlock remote 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"
@ -1103,7 +1125,7 @@ function _UnlockReplicasRemote {
} }
function UnlockReplicas { function UnlockReplicas {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ $_NOLOCKS -eq 1 ]; then if [ $_NOLOCKS -eq 1 ]; then
return 0 return 0
@ -1128,7 +1150,7 @@ function tree_list {
local replica_path="${1}" # path to the replica for which a tree needs to be constructed local replica_path="${1}" # path to the replica for which a tree needs to be constructed
local replica_type="${2}" # replica type: initiator, target local replica_type="${2}" # replica type: initiator, target
local tree_filename="${3}" # filename to output tree (will be prefixed with $replica_type) local tree_filename="${3}" # filename to output tree (will be prefixed with $replica_type)
__CheckArguments 3 $# $FUNCNAME "$*" __CheckArguments 3 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
local escaped_replica_path=$(EscapeSpaces "$replica_path") #TODO: See if escpaed still needed when using ' instead of " for command eval local escaped_replica_path=$(EscapeSpaces "$replica_path") #TODO: See if escpaed still needed when using ' instead of " for command eval
@ -1144,7 +1166,7 @@ function tree_list {
## Redirect commands stderr here to get rsync stderr output in logfile ## Redirect commands stderr here to get rsync stderr output in logfile
eval $rsync_cmd 2>> "$LOG_FILE" eval $rsync_cmd 2>> "$LOG_FILE"
child_pid=$! child_pid=$!
WaitForCompletion $child_pid $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME WaitForCompletion $child_pid $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME $FUNCNAME
retval=$? retval=$?
## Retval 24 = some files vanished while creating list ## Retval 24 = some files vanished while creating list
if ([ $retval == 0 ] || [ $retval == 24 ]) && [ -f $RUN_DIR/osync_$replica_type_$SCRIPT_PID ]; then if ([ $retval == 0 ] || [ $retval == 24 ]) && [ -f $RUN_DIR/osync_$replica_type_$SCRIPT_PID ]; then
@ -1163,7 +1185,7 @@ function delete_list {
local tree_file_current="${3}" # tree-file-current, will be prefixed with replica type local tree_file_current="${3}" # tree-file-current, will be prefixed with replica type
local deleted_list_file="${4}" # file containing deleted file list, will be prefixed with replica type local deleted_list_file="${4}" # file containing deleted file list, will be prefixed with replica type
local deleted_failed_list_file="${5}" # file containing files that couldn't be deleted on last run, will be prefixed with replica type local deleted_failed_list_file="${5}" # file containing files that couldn't be deleted on last run, will be prefixed with replica type
__CheckArguments 5 $# $FUNCNAME "$*" __CheckArguments 5 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
# TODO: Check why external filenames are used (see _DRYRUN option because of NOSUFFIX) # TODO: Check why external filenames are used (see _DRYRUN option because of NOSUFFIX)
@ -1200,7 +1222,7 @@ function sync_update {
local source_replica="${1}" # Contains replica type of source: initiator, target local source_replica="${1}" # Contains replica type of source: initiator, target
local destination_replica="${2}" # Contains replica type of destination: initiator, target local destination_replica="${2}" # Contains replica type of destination: initiator, target
local delete_list_filename="${3}" # Contains deleted list filename, will be prefixed with replica type local delete_list_filename="${3}" # Contains deleted list filename, will be prefixed with replica type
__CheckArguments 3 $# $FUNCNAME "$*" __CheckArguments 3 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
Logger "Updating $destination_replica replica." "NOTICE" Logger "Updating $destination_replica replica." "NOTICE"
if [ "$source_replica" == "initiator" ]; then if [ "$source_replica" == "initiator" ]; then
@ -1231,7 +1253,7 @@ function sync_update {
Logger "RSYNC_CMD: $rsync_cmd" "DEBUG" Logger "RSYNC_CMD: $rsync_cmd" "DEBUG"
eval "$rsync_cmd" eval "$rsync_cmd"
child_pid=$! child_pid=$!
WaitForCompletion $child_pid $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME WaitForCompletion $child_pid $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME $FUNCNAME
retval=$? retval=$?
if [ $_VERBOSE -eq 1 ] && [ -f $RUN_DIR/osync_update_$destination_replica_replica_$SCRIPT_PID ]; then if [ $_VERBOSE -eq 1 ] && [ -f $RUN_DIR/osync_update_$destination_replica_replica_$SCRIPT_PID ]; then
Logger "List:\n$(cat $RUN_DIR/osync_update_$destination_replica_replica_$SCRIPT_PID)" "NOTICE" Logger "List:\n$(cat $RUN_DIR/osync_update_$destination_replica_replica_$SCRIPT_PID)" "NOTICE"
@ -1255,7 +1277,7 @@ function _delete_local {
local deleted_list_file="${2}" # file containing deleted file list, will be prefixed with replica type local deleted_list_file="${2}" # file containing deleted file list, will be prefixed with replica type
local deletion_dir="${3}" # deletion dir in format .[workdir]/deleted local deletion_dir="${3}" # deletion dir in format .[workdir]/deleted
local deleted_failed_list_file="${4}" # file containing files that couldn't be deleted on last run, will be prefixed with replica type local deleted_failed_list_file="${4}" # file containing files that couldn't be deleted on last run, will be prefixed with replica type
__CheckArguments 4 $# $FUNCNAME "$*" __CheckArguments 4 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
## On every run, check wheter the next item is already deleted because it's included in a directory already deleted ## On every run, check wheter the next item is already deleted because it's included in a directory already deleted
previous_file="" previous_file=""
@ -1317,7 +1339,7 @@ function _delete_remote {
local deleted_list_file="${2}" # file containing deleted file list, will be prefixed with replica type local deleted_list_file="${2}" # file containing deleted file list, will be prefixed with replica type
local deletion_dir="${3}" # deletion dir in format .[workdir]/deleted local deletion_dir="${3}" # deletion dir in format .[workdir]/deleted
local deleted_failed_list_file="${4}" # file containing files that couldn't be deleted on last run, will be prefixed with replica type local deleted_failed_list_file="${4}" # file containing files that couldn't be deleted on last run, will be prefixed with replica type
__CheckArguments 4 $# $FUNCNAME "$*" __CheckArguments 4 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
## This is a special coded function. Need to redelcare local functions on remote host, passing all needed variables as escaped arguments to ssh command. ## This is a special coded function. Need to redelcare local functions on remote host, passing all needed variables as escaped arguments to ssh command.
## Anything beetween << ENDSSH and ENDSSH will be executed remotely ## Anything beetween << ENDSSH and ENDSSH will be executed remotely
@ -1463,7 +1485,7 @@ function deletion_propagation {
local replica_type="${1}" # Contains replica type: initiator, target local replica_type="${1}" # Contains replica type: initiator, target
local deleted_list_file="${2}" # file containing deleted file list, will be prefixed with replica type local deleted_list_file="${2}" # file containing deleted file list, will be prefixed with replica type
local deleted_failed_list_file="${3}" # file containing files that couldn't be deleted on last run, will be prefixed with replica type local deleted_failed_list_file="${3}" # file containing files that couldn't be deleted on last run, will be prefixed with replica type
__CheckArguments 3 $# $FUNCNAME "$*" __CheckArguments 3 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
Logger "Propagating deletions to $replica_type replica." "NOTICE" Logger "Propagating deletions to $replica_type replica." "NOTICE"
@ -1473,7 +1495,7 @@ function deletion_propagation {
_delete_local "$REPLICA_DIR" "target$deleted_list_file" "$DELETE_DIR" "target$deleted_failed_list_file" & _delete_local "$REPLICA_DIR" "target$deleted_list_file" "$DELETE_DIR" "target$deleted_failed_list_file" &
child_pid=$! child_pid=$!
WaitForCompletion $child_pid $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME WaitForCompletion $child_pid $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME $FUNCNAME
retval=$? retval=$?
if [ $retval != 0 ]; then if [ $retval != 0 ]; then
Logger "Deletion on replica $replica_type failed." "CRITICAL" Logger "Deletion on replica $replica_type failed." "CRITICAL"
@ -1489,7 +1511,7 @@ function deletion_propagation {
_delete_local "$REPLICA_DIR" "initiator$deleted_list_file" "$DELETE_DIR" "initiator$deleted_failed_list_file" & _delete_local "$REPLICA_DIR" "initiator$deleted_list_file" "$DELETE_DIR" "initiator$deleted_failed_list_file" &
fi fi
child_pid=$! child_pid=$!
WaitForCompletion $child_pid $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME WaitForCompletion $child_pid $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME $FUNCNAME
retval=$? retval=$?
if [ $retval == 0 ]; then if [ $retval == 0 ]; then
if [ -f $RUN_DIR/osync_remote_deletion_$SCRIPT_PID ] && [ $_VERBOSE -eq 1 ]; then if [ -f $RUN_DIR/osync_remote_deletion_$SCRIPT_PID ] && [ $_VERBOSE -eq 1 ]; then
@ -1515,7 +1537,7 @@ function deletion_propagation {
###### Step 5: Create after run tree list for initiator and target replicas (Steps 5M and 5S) ###### Step 5: Create after run tree list for initiator and target replicas (Steps 5M and 5S)
function Sync { function Sync {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
Logger "Starting synchronization task." "NOTICE" Logger "Starting synchronization task." "NOTICE"
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
@ -1678,7 +1700,7 @@ function _SoftDeleteLocal {
local replica_type="${1}" # replica type (initiator, target) local replica_type="${1}" # replica type (initiator, target)
local replica_deletion_path="${2}" # Contains the full path to softdelete / backup directory without ending slash local replica_deletion_path="${2}" # Contains the full path to softdelete / backup directory without ending slash
local change_time="${3}" local change_time="${3}"
__CheckArguments 3 $# $FUNCNAME "$*" __CheckArguments 3 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ -d "$replica_deletion_path" ]; then if [ -d "$replica_deletion_path" ]; then
if [ $_DRYRUN -eq 1 ]; then if [ $_DRYRUN -eq 1 ]; then
@ -1698,7 +1720,7 @@ function _SoftDeleteLocal {
else else
Dummy & Dummy &
fi fi
WaitForCompletion $? $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME 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"
@ -1715,7 +1737,7 @@ function _SoftDeleteRemote {
local replica_type="${1}" local replica_type="${1}"
local replica_deletion_path="${2}" # Contains the full path to softdelete / backup directory without ending slash local replica_deletion_path="${2}" # Contains the full path to softdelete / backup directory without ending slash
local change_time"${3}" local change_time"${3}"
__CheckArguments 3 $# $FUNCNAME "$*" __CheckArguments 3 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
@ -1737,7 +1759,7 @@ function _SoftDeleteRemote {
else else
Dummy & Dummy &
fi fi
WaitForCompletion $? $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME 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 remote target replica." "ERROR" Logger "Error while executing cleanup on remote target replica." "ERROR"
@ -1748,7 +1770,7 @@ function _SoftDeleteRemote {
} }
function SoftDelete { function SoftDelete {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if [ "$CONFLICT_BACKUP" != "no" ] && [ $CONFLICT_BACKUP_DAYS -ne 0 ]; then if [ "$CONFLICT_BACKUP" != "no" ] && [ $CONFLICT_BACKUP_DAYS -ne 0 ]; then
Logger "Running conflict backup cleanup." "NOTICE" Logger "Running conflict backup cleanup." "NOTICE"
@ -1774,7 +1796,7 @@ function SoftDelete {
} }
function Init { function Init {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
# Set error exit code if a piped command fails # Set error exit code if a piped command fails
set -o pipefail set -o pipefail
@ -2004,7 +2026,7 @@ function Init {
} }
function InitLocalOSSettings { function InitLocalOSSettings {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
## If running under Msys, some commands don't run the same way ## If running under Msys, some commands don't run the same way
## Using mingw version of find instead of windows one ## Using mingw version of find instead of windows one
@ -2032,7 +2054,7 @@ function InitLocalOSSettings {
} }
function InitRemoteOSSettings { function InitRemoteOSSettings {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
## MacOSX does not use the -E parameter like Linux or BSD does (-E is mapped to extended attrs instead of preserve executability) ## MacOSX does not use the -E parameter like Linux or BSD does (-E is mapped to extended attrs instead of preserve executability)
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ]; then if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ]; then
@ -2047,7 +2069,7 @@ function InitRemoteOSSettings {
} }
function Main { function Main {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
CreateStateDirs CreateStateDirs
CheckLocks CheckLocks
@ -2055,6 +2077,8 @@ function Main {
} }
function Usage { function Usage {
__CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
echo "$PROGRAM $PROGRAM_VERSION $PROGRAM_BUILD" echo "$PROGRAM $PROGRAM_VERSION $PROGRAM_BUILD"
echo $AUTHOR echo $AUTHOR
echo $CONTACT echo $CONTACT
@ -2088,7 +2112,7 @@ function Usage {
} }
function SyncOnChanges { function SyncOnChanges {
__CheckArguments 0 $# $FUNCNAME "$*" __CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
if ! type -p inotifywait > /dev/null 2>&1 if ! type -p inotifywait > /dev/null 2>&1
then then

Loading…
Cancel
Save