Added WaitForTaskCompletion to remote connectivity checks
This commit is contained in:
parent
5bca46e3cf
commit
b34e53da71
|
@ -13,14 +13,17 @@ RECENT CHANGES
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
! Check for deletion failed list file before trying to copy it back
|
! Check for deletion failed list file before trying to copy it back
|
||||||
! Added v1.0x to v1.1 upgrade script
|
- Passed shellCheck.net
|
||||||
|
- Simplified EscapeSpaces to simple bash substitution
|
||||||
|
- Corrected a lot of minor warnings in order to make code more bullet proof
|
||||||
|
- Added basic v1.0x to v1.1 upgrade script
|
||||||
- Added (much) more verbose debugging (and possibility to remove debug code to gain speed)
|
- 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
|
||||||
! Add Logger DEBUG to all eval statements
|
- Add Logger DEBUG to all eval statements
|
||||||
- Unlocking happens after TrapQuit has successfully killed any child processes
|
- Unlocking happens after TrapQuit has successfully killed any child processes
|
||||||
- Replace child_pid by $? directly, add a better sub process killer in TrapQuit
|
- Replace child_pid by $? directly, add a better sub process killer in TrapQuit
|
||||||
- Refactor [local master, local slave, remote slave] code to [local, remote][initiator, target]code
|
- Refactor [local master, local slave, remote slave] code to [local, remote][initiator, target]code
|
||||||
- Added some automatic typo checks in code, for _DEBUG mode (and _PARANOIA_DEBUG now)
|
- Added some automatic checks in code, for _DEBUG mode (and _PARANOIA_DEBUG now)
|
||||||
- Improved Logging
|
- Improved Logging
|
||||||
- Updated osync to be fully compliant with coding style
|
- Updated osync to be fully compliant with coding style
|
||||||
- Uploaded coding style manifest
|
- Uploaded coding style manifest
|
||||||
|
|
17
osync.sh
17
osync.sh
|
@ -4,9 +4,9 @@ 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=2015092306
|
PROGRAM_BUILD=2015092402
|
||||||
|
|
||||||
## type doesn't work on platforms other than linux (bash). If if doesn't work, always assume output is not a zero exitcode
|
## type does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
|
||||||
if ! type -p "$BASH" > /dev/null; then
|
if ! type -p "$BASH" > /dev/null; then
|
||||||
echo "Please run this script only with bash shell. Tested on bash >= 3.2"
|
echo "Please run this script only with bash shell. Tested on bash >= 3.2"
|
||||||
exit 127
|
exit 127
|
||||||
|
@ -225,6 +225,11 @@ function Spinner {
|
||||||
}
|
}
|
||||||
|
|
||||||
function EscapeSpaces {
|
function EscapeSpaces {
|
||||||
|
local string="${1}" # String on which spaces will be escaped
|
||||||
|
echo "${string// /\ }"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _Legacy_EscapeSpaces {
|
||||||
local string="${1}" # String on which spaces will be escaped
|
local string="${1}" # String on which spaces will be escaped
|
||||||
echo $(echo "$string" | sed 's/ /\\ /g')
|
echo $(echo "$string" | sed 's/ /\\ /g')
|
||||||
}
|
}
|
||||||
|
@ -614,7 +619,8 @@ function CheckConnectivityRemoteHost {
|
||||||
__CheckArguments 0 $# $FUNCNAME "$*" #__WITH_PARANOIA_DEBUG
|
__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" &
|
||||||
|
WaitForTaskCompletion $! 180 180 $FUNCNAME
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot ping $REMOTE_HOST" "CRITICAL"
|
Logger "Cannot ping $REMOTE_HOST" "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -631,7 +637,8 @@ function CheckConnectivity3rdPartyHosts {
|
||||||
IFS=$' \t\n'
|
IFS=$' \t\n'
|
||||||
for i in $REMOTE_3RD_PARTY_HOSTS
|
for i in $REMOTE_3RD_PARTY_HOSTS
|
||||||
do
|
do
|
||||||
eval "$PING_CMD $i > /dev/null 2>&1"
|
eval "$PING_CMD $i > /dev/null 2>&1" &
|
||||||
|
WaitForTaskCompletion $! 360 360 $FUNCNAME
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot ping 3rd party host $i" "WARN"
|
Logger "Cannot ping 3rd party host $i" "WARN"
|
||||||
else
|
else
|
||||||
|
@ -666,7 +673,7 @@ function __CheckArguments {
|
||||||
done
|
done
|
||||||
if [ $count -ne $1 ]; then
|
if [ $count -ne $1 ]; then
|
||||||
Logger "Function $function_name may have inconsistent number of arguments. Expected: $number_of_arguments, count: $count, see log file." "WARN"
|
Logger "Function $function_name may have inconsistent number of arguments. Expected: $number_of_arguments, count: $count, see log file." "WARN"
|
||||||
echo "Argument list (including checks): $@" >> "$LOG_FILE"
|
echo "Argument list (including checks): $*" >> "$LOG_FILE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue