From 01725786f165655650517df1c91a5fb084eb6722 Mon Sep 17 00:00:00 2001 From: deajan Date: Tue, 16 Aug 2016 22:40:02 +0200 Subject: [PATCH] Rebuilt targets --- dev/debug_obackup.sh | 35 +++++++++++++++++------------------ obackup.sh | 35 +++++++++++++++++------------------ 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/dev/debug_obackup.sh b/dev/debug_obackup.sh index 0b9cf02..ab57c44 100755 --- a/dev/debug_obackup.sh +++ b/dev/debug_obackup.sh @@ -7,12 +7,12 @@ PROGRAM="obackup" AUTHOR="(C) 2013-2016 by Orsiris de Jong" CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr" PROGRAM_VERSION=2.1-dev -PROGRAM_BUILD=2016081601 +PROGRAM_BUILD=2016081602 IS_STABLE=no #### MINIMAL-FUNCTION-SET BEGIN #### -## FUNC_BUILD=2016081603 +## FUNC_BUILD=2016081605 ## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode @@ -33,6 +33,9 @@ _SILENT=0 _LOGGER_PREFIX="date" _LOGGER_STDERR=0 +if [ $(isNumeric "$KEEP_LOGGING") -ne 1 ]; then + KEEP_LOGGING=1801 +fi # Initial error status, logging 'WARN', 'ERROR' or 'CRITICAL' will enable alerts flags ERROR_ALERT=0 @@ -180,8 +183,8 @@ function QuickLogger { # Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X function KillChilds { - local pid="${1}" # Parent pid to kill - local self="${2:-false}" + local pid="${1}" # Parent pid to kill childs + local self="${2:-false}" # Should parent be killed too ? if children="$(pgrep -P "$pid")"; then @@ -658,7 +661,7 @@ function WaitForTaskCompletion { if [ $exec_time -gt $hard_max_time ] && [ $hard_max_time -ne 0 ]; then Logger "Max hard execution time exceeded for task [$caller_name] with pids [$(joinString , ${pidsArray[@]})]. Stopping task execution." "ERROR" for pid in "${pidsArray[@]}"; do - KillChilds $pid + KillChilds $pid true if [ $? == 0 ]; then Logger "Task with pid [$pid] stopped successfully." "NOTICE" else @@ -812,19 +815,19 @@ function GetRemoteOS { cmd=$SSH_CMD' "uname -spio" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1' Logger "cmd: $cmd" "DEBUG" eval "$cmd" & - WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-1" false true + WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-1" false true $KEEP_LOGGING retval=$? if [ $retval != 0 ]; then cmd=$SSH_CMD' "uname -v" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1' Logger "cmd: $cmd" "DEBUG" eval "$cmd" & - WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-2" false true + WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-2" false true $KEEP_LOGGING retval=$? if [ $retval != 0 ]; then cmd=$SSH_CMD' "uname" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1' Logger "cmd: $cmd" "DEBUG" eval "$cmd" & - WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-3" false true + WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-3" false true $KEEP_LOGGING retval=$? if [ $retval != 0 ]; then Logger "Cannot Get remote OS type." "ERROR" @@ -877,7 +880,7 @@ function RunLocalCommand { Logger "Running command [$command] on local host." "NOTICE" eval "$command" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" 2>&1 & - WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} false true + WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} false true $KEEP_LOGGING retval=$? if [ $retval -eq 0 ]; then Logger "Command succeded." "NOTICE" @@ -912,7 +915,7 @@ function RunRemoteCommand { cmd=$SSH_CMD' "$command" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1' Logger "cmd: $cmd" "DEBUG" eval "$cmd" & - WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} false true + WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} false true $KEEP_LOGGING retval=$? if [ $retval -eq 0 ]; then Logger "Command succeded." "NOTICE" @@ -946,7 +949,7 @@ function RunBeforeHook { pids="$pids;$!" fi if [ "$pids" != "" ]; then - WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true + WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true $KEEP_LOGGING fi } @@ -965,7 +968,7 @@ function RunAfterHook { pids="$pids;$!" fi if [ "$pids" != "" ]; then - WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true + WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true $KEEP_LOGGING fi } @@ -976,7 +979,7 @@ function CheckConnectivityRemoteHost { if [ "$REMOTE_HOST_PING" != "no" ] && [ "$REMOTE_OPERATION" != "no" ]; then eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" & - WaitForTaskCompletion $! 10 180 ${FUNCNAME[0]} false true + WaitForTaskCompletion $! 10 180 ${FUNCNAME[0]} false true $KEEP_LOGGING if [ $? != 0 ]; then Logger "Cannot ping $REMOTE_HOST" "ERROR" return 1 @@ -998,7 +1001,7 @@ function CheckConnectivity3rdPartyHosts { for i in $REMOTE_3RD_PARTY_HOSTS do eval "$PING_CMD $i > /dev/null 2>&1" & - WaitForTaskCompletion $! 10 360 ${FUNCNAME[0]} false true + WaitForTaskCompletion $! 10 360 ${FUNCNAME[0]} false true $KEEP_LOGGING if [ $? != 0 ]; then Logger "Cannot ping 3rd party host $i" "NOTICE" else @@ -2649,10 +2652,6 @@ else LOG_FILE="$LOGFILE" fi -if [ $(isNumeric "$KEEP_LOGGING") -ne 1 ]; then - KEEP_LOGGING=1801 -fi - if [ "$IS_STABLE" != "yes" ]; then Logger "This is an unstable dev build. Please use with caution." "WARN" fi diff --git a/obackup.sh b/obackup.sh index a727798..3ffec13 100755 --- a/obackup.sh +++ b/obackup.sh @@ -7,12 +7,12 @@ PROGRAM="obackup" AUTHOR="(C) 2013-2016 by Orsiris de Jong" CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr" PROGRAM_VERSION=2.1-dev -PROGRAM_BUILD=2016081601 +PROGRAM_BUILD=2016081602 IS_STABLE=no #### MINIMAL-FUNCTION-SET BEGIN #### -## FUNC_BUILD=2016081603 +## FUNC_BUILD=2016081605 ## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode @@ -33,6 +33,9 @@ _SILENT=0 _LOGGER_PREFIX="date" _LOGGER_STDERR=0 +if [ $(isNumeric "$KEEP_LOGGING") -ne 1 ]; then + KEEP_LOGGING=1801 +fi # Initial error status, logging 'WARN', 'ERROR' or 'CRITICAL' will enable alerts flags ERROR_ALERT=0 @@ -168,8 +171,8 @@ function QuickLogger { # Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X function KillChilds { - local pid="${1}" # Parent pid to kill - local self="${2:-false}" + local pid="${1}" # Parent pid to kill childs + local self="${2:-false}" # Should parent be killed too ? if children="$(pgrep -P "$pid")"; then @@ -639,7 +642,7 @@ function WaitForTaskCompletion { if [ $exec_time -gt $hard_max_time ] && [ $hard_max_time -ne 0 ]; then Logger "Max hard execution time exceeded for task [$caller_name] with pids [$(joinString , ${pidsArray[@]})]. Stopping task execution." "ERROR" for pid in "${pidsArray[@]}"; do - KillChilds $pid + KillChilds $pid true if [ $? == 0 ]; then Logger "Task with pid [$pid] stopped successfully." "NOTICE" else @@ -789,19 +792,19 @@ function GetRemoteOS { cmd=$SSH_CMD' "uname -spio" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1' Logger "cmd: $cmd" "DEBUG" eval "$cmd" & - WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-1" false true + WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-1" false true $KEEP_LOGGING retval=$? if [ $retval != 0 ]; then cmd=$SSH_CMD' "uname -v" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1' Logger "cmd: $cmd" "DEBUG" eval "$cmd" & - WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-2" false true + WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-2" false true $KEEP_LOGGING retval=$? if [ $retval != 0 ]; then cmd=$SSH_CMD' "uname" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1' Logger "cmd: $cmd" "DEBUG" eval "$cmd" & - WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-3" false true + WaitForTaskCompletion $! 120 240 ${FUNCNAME[0]}"-3" false true $KEEP_LOGGING retval=$? if [ $retval != 0 ]; then Logger "Cannot Get remote OS type." "ERROR" @@ -853,7 +856,7 @@ function RunLocalCommand { Logger "Running command [$command] on local host." "NOTICE" eval "$command" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" 2>&1 & - WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} false true + WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} false true $KEEP_LOGGING retval=$? if [ $retval -eq 0 ]; then Logger "Command succeded." "NOTICE" @@ -887,7 +890,7 @@ function RunRemoteCommand { cmd=$SSH_CMD' "$command" > "'$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID'" 2>&1' Logger "cmd: $cmd" "DEBUG" eval "$cmd" & - WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} false true + WaitForTaskCompletion $! 0 $hard_max_time ${FUNCNAME[0]} false true $KEEP_LOGGING retval=$? if [ $retval -eq 0 ]; then Logger "Command succeded." "NOTICE" @@ -920,7 +923,7 @@ function RunBeforeHook { pids="$pids;$!" fi if [ "$pids" != "" ]; then - WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true + WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true $KEEP_LOGGING fi } @@ -938,7 +941,7 @@ function RunAfterHook { pids="$pids;$!" fi if [ "$pids" != "" ]; then - WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true + WaitForTaskCompletion $pids 0 0 ${FUNCNAME[0]} false true $KEEP_LOGGING fi } @@ -948,7 +951,7 @@ function CheckConnectivityRemoteHost { if [ "$REMOTE_HOST_PING" != "no" ] && [ "$REMOTE_OPERATION" != "no" ]; then eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" & - WaitForTaskCompletion $! 10 180 ${FUNCNAME[0]} false true + WaitForTaskCompletion $! 10 180 ${FUNCNAME[0]} false true $KEEP_LOGGING if [ $? != 0 ]; then Logger "Cannot ping $REMOTE_HOST" "ERROR" return 1 @@ -969,7 +972,7 @@ function CheckConnectivity3rdPartyHosts { for i in $REMOTE_3RD_PARTY_HOSTS do eval "$PING_CMD $i > /dev/null 2>&1" & - WaitForTaskCompletion $! 10 360 ${FUNCNAME[0]} false true + WaitForTaskCompletion $! 10 360 ${FUNCNAME[0]} false true $KEEP_LOGGING if [ $? != 0 ]; then Logger "Cannot ping 3rd party host $i" "NOTICE" else @@ -2537,10 +2540,6 @@ else LOG_FILE="$LOGFILE" fi -if [ $(isNumeric "$KEEP_LOGGING") -ne 1 ]; then - KEEP_LOGGING=1801 -fi - if [ "$IS_STABLE" != "yes" ]; then Logger "This is an unstable dev build. Please use with caution." "WARN" fi