|
|
|
@ -7,7 +7,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
|
|
|
|
|
AUTHOR="(C) 2013-2019 by Orsiris de Jong"
|
|
|
|
|
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
|
|
|
|
PROGRAM_VERSION=1.3.0-beta3+dev
|
|
|
|
|
PROGRAM_BUILD=2019052202
|
|
|
|
|
PROGRAM_BUILD=2019052203
|
|
|
|
|
IS_STABLE=false
|
|
|
|
|
|
|
|
|
|
CONFIG_FILE_REVISION_REQUIRED=1.3.0
|
|
|
|
@ -43,7 +43,7 @@ CONFIG_FILE_REVISION_REQUIRED=1.3.0
|
|
|
|
|
# CleanUp no #__WITH_PARANOIA_DEBUG
|
|
|
|
|
|
|
|
|
|
_OFUNCTIONS_VERSION=2.3.0-dev-postRC2
|
|
|
|
|
_OFUNCTIONS_BUILD=2019052201
|
|
|
|
|
_OFUNCTIONS_BUILD=2019052203
|
|
|
|
|
_OFUNCTIONS_BOOTSTRAP=true
|
|
|
|
|
|
|
|
|
|
if ! type "$BASH" > /dev/null; then
|
|
|
|
@ -195,7 +195,7 @@ function _Logger {
|
|
|
|
|
|
|
|
|
|
# Build current log file for alerts if we have a sufficient environment
|
|
|
|
|
if [ "$RUN_DIR/$PROGRAM" != "/" ]; then
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP.log"
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -496,7 +496,7 @@ function SendAlert {
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
body="$MAIL_ALERT_MSG"$'\n\n'"Last 1000 lines of current log"$'\n\n'"$(tail -n 1000 "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP.log")"
|
|
|
|
|
body="$MAIL_ALERT_MSG"$'\n\n'"Last 1000 lines of current log"$'\n\n'"$(tail -n 1000 "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP")"
|
|
|
|
|
|
|
|
|
|
if [ $ERROR_ALERT == true ]; then
|
|
|
|
|
subject="Error alert for $INSTANCE_ID"
|
|
|
|
@ -574,7 +574,7 @@ function SendEmail {
|
|
|
|
|
if [ "$MAIL_BODY_CHARSET" != "" ]; then
|
|
|
|
|
if type iconv > /dev/null 2>&1; then
|
|
|
|
|
echo "$message" | iconv -f UTF-8 -t $MAIL_BODY_CHARSET -o "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.iconv.$SCRIPT_PID.$TSTAMP"
|
|
|
|
|
message="$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.iconv.$SCRIPT_PID.$TSTAMP)"
|
|
|
|
|
message="$(cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.iconv.$SCRIPT_PID.$TSTAMP")"
|
|
|
|
|
else
|
|
|
|
|
Logger "iconv utility not installed. Will not convert email charset." "NOTICE"
|
|
|
|
|
fi
|
|
|
|
@ -1107,7 +1107,7 @@ function ExecTasks {
|
|
|
|
|
Logger "Command was [${commandsArrayPid[$pid]}]." "ERROR"
|
|
|
|
|
fi
|
|
|
|
|
if [ -f "${commandsArrayOutput[$pid]}" ]; then
|
|
|
|
|
Logger "Command output was [$(cat ${commandsArrayOutput[$pid]})\n]." "ERROR"
|
|
|
|
|
Logger "Command output was [$(cat "${commandsArrayOutput[$pid]}")\n]." "ERROR"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
errorcount=$((errorcount+1))
|
|
|
|
@ -1209,7 +1209,7 @@ function ExecTasks {
|
|
|
|
|
postponedRetryCount=0
|
|
|
|
|
postponedExecTime=0
|
|
|
|
|
fi
|
|
|
|
|
if ([ $postponedRetryCount -lt $maxPostponeRetries ] && [ $postponedExecTime -ge $((minTimeBetweenRetries)) ]) || [ $isPostponedCommand == false ]; then
|
|
|
|
|
if ([ $postponedRetryCount -lt $maxPostponeRetries ] && [ $postponedExecTime -ge $minTimeBetweenRetries ]) || [ $isPostponedCommand == false ]; then
|
|
|
|
|
if [ "$currentCommandCondition" != "" ]; then
|
|
|
|
|
Logger "Checking condition [$currentCommandCondition] for command [$currentCommand]." "DEBUG"
|
|
|
|
|
eval "$currentCommandCondition" &
|
|
|
|
@ -1759,7 +1759,7 @@ function RunLocalCommand {
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $_LOGGER_VERBOSE == true ] || [ $retval -ne 0 ]; then
|
|
|
|
|
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
|
|
|
|
Logger "Command output:\n$(cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$STOP_ON_CMD_ERROR" == true ] && [ $retval -ne 0 ]; then
|
|
|
|
@ -1802,7 +1802,7 @@ function RunRemoteCommand {
|
|
|
|
|
|
|
|
|
|
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ] && ([ $_LOGGER_VERBOSE == true ] || [ $retval -ne 0 ])
|
|
|
|
|
then
|
|
|
|
|
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
|
|
|
|
Logger "Command output:\n$(cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "NOTICE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$STOP_ON_CMD_ERROR" == true ] && [ $retval -ne 0 ]; then
|
|
|
|
@ -1941,8 +1941,8 @@ function RsyncPatternsFromAdd {
|
|
|
|
|
__CheckArguments 2 $# "$@" #__WITH_PARANOIA_DEBUG
|
|
|
|
|
|
|
|
|
|
## Check if the exclude list has a full path, and if not, add the config file path if there is one
|
|
|
|
|
if [ "$(basename $patternFrom)" == "$patternFrom" ]; then
|
|
|
|
|
patternFrom="$(dirname $CONFIG_FILE)/$patternFrom"
|
|
|
|
|
if [ "$(basename "$patternFrom")" == "$patternFrom" ]; then
|
|
|
|
|
patternFrom="$(dirname "$CONFIG_FILE")/$patternFrom"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -e "$patternFrom" ]; then
|
|
|
|
@ -2165,7 +2165,7 @@ function InitRemoteOSDependingSettings {
|
|
|
|
|
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
|
|
|
|
|
|
|
|
|
|
if [ "$REMOTE_OS" == "msys" ] || [ "$REMOTE_OS" == "Cygwin" ]; then
|
|
|
|
|
REMOTE_FIND_CMD=$(dirname $BASH)/find
|
|
|
|
|
REMOTE_FIND_CMD="$(dirname $BASH)/find"
|
|
|
|
|
else
|
|
|
|
|
REMOTE_FIND_CMD=find
|
|
|
|
|
fi
|
|
|
|
@ -2779,7 +2779,7 @@ function _Logger {
|
|
|
|
|
|
|
|
|
|
# Build current log file for alerts if we have a sufficient environment
|
|
|
|
|
if [ "$RUN_DIR/$PROGRAM" != "/" ]; then
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP.log"
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -3145,7 +3145,7 @@ function _Logger {
|
|
|
|
|
|
|
|
|
|
# Build current log file for alerts if we have a sufficient environment
|
|
|
|
|
if [ "$RUN_DIR/$PROGRAM" != "/" ]; then
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP.log"
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -3756,7 +3756,7 @@ function _Logger {
|
|
|
|
|
|
|
|
|
|
# Build current log file for alerts if we have a sufficient environment
|
|
|
|
|
if [ "$RUN_DIR/$PROGRAM" != "/" ]; then
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP.log"
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -4406,7 +4406,7 @@ function _Logger {
|
|
|
|
|
|
|
|
|
|
# Build current log file for alerts if we have a sufficient environment
|
|
|
|
|
if [ "$RUN_DIR/$PROGRAM" != "/" ]; then
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP.log"
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -4706,8 +4706,6 @@ function Initialize {
|
|
|
|
|
###### Step 8a & 8b: Create after run ctime & mtime file list of replicas
|
|
|
|
|
|
|
|
|
|
function Sync {
|
|
|
|
|
local syncType="${1}" # Optional sync type. By default, sync is bidirectional.
|
|
|
|
|
|
|
|
|
|
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
|
|
|
|
|
|
|
|
|
|
local resumeCount
|
|
|
|
@ -5383,7 +5381,7 @@ function _Logger {
|
|
|
|
|
|
|
|
|
|
# Build current log file for alerts if we have a sufficient environment
|
|
|
|
|
if [ "$RUN_DIR/$PROGRAM" != "/" ]; then
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP.log"
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -5657,7 +5655,7 @@ function _Logger {
|
|
|
|
|
|
|
|
|
|
# Build current log file for alerts if we have a sufficient environment
|
|
|
|
|
if [ "$RUN_DIR/$PROGRAM" != "/" ]; then
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP.log"
|
|
|
|
|
echo -e "$logValue" >> "$RUN_DIR/$PROGRAM._Logger.$SCRIPT_PID.$TSTAMP"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|