Merge pull request #244 from zhemant/fix/operator-error
Fix/operator error
This commit is contained in:
commit
f2761d6a42
|
@ -42,8 +42,8 @@ CONFIG_FILE_REVISION_REQUIRED=1.3.0
|
||||||
# UnlockReplicas yes #__WITH_PARANOIA_DEBUG
|
# UnlockReplicas yes #__WITH_PARANOIA_DEBUG
|
||||||
# CleanUp no #__WITH_PARANOIA_DEBUG
|
# CleanUp no #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
_OFUNCTIONS_VERSION=2.3.0-RC4
|
_OFUNCTIONS_VERSION=2.3.2
|
||||||
_OFUNCTIONS_BUILD=2020111502
|
_OFUNCTIONS_BUILD=2021051801
|
||||||
_OFUNCTIONS_BOOTSTRAP=true
|
_OFUNCTIONS_BOOTSTRAP=true
|
||||||
|
|
||||||
if ! type "$BASH" > /dev/null; then
|
if ! type "$BASH" > /dev/null; then
|
||||||
|
@ -1852,6 +1852,42 @@ function RunAfterHook {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function TimeCheck {
|
||||||
|
# Checks if more than deltatime seconds have passed since last check, which is stored in timefile
|
||||||
|
__CheckArguments 2 $# "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
|
local timefile="${1}"
|
||||||
|
local deltatime="${2}"
|
||||||
|
|
||||||
|
if [ -f "$timefile" ]; then
|
||||||
|
result=$(cat "$timefile")
|
||||||
|
tstamp=$(date +%s)
|
||||||
|
if [ $((tstamp-result)) -gt $deltatime ]; then
|
||||||
|
echo "$(date +%s)" > "$timefile"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "$(date +%s)" > "$timefile"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function Ping {
|
||||||
|
# Simple ping check
|
||||||
|
__CheckArguments 1 $# "$@"
|
||||||
|
|
||||||
|
local host="${1}"
|
||||||
|
|
||||||
|
local retval
|
||||||
|
|
||||||
|
eval "$PING_CMD $host > /dev/null 2>&1" &
|
||||||
|
ExecTasks $! "${FUNCNAME[0]}" false 0 0 60 180 true $SLEEP_TIME $KEEP_LOGGING
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function CheckConnectivityRemoteHost {
|
function CheckConnectivityRemoteHost {
|
||||||
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
|
@ -1872,7 +1908,13 @@ function CheckConnectivityRemoteHost {
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckConnectivity3rdPartyHosts {
|
function CheckConnectivity3rdPartyHosts {
|
||||||
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
|
# Check if at least one host is reachable in order to diag internet
|
||||||
|
# third_party_hosts_ips=('1.1.1.1' '8.8.8.8' 'kernel.org' 'google.com')
|
||||||
|
# CheckConnectivity3rdPartyHosts $third_party_hosts_ips
|
||||||
|
|
||||||
|
__CheckArguments 0-1 $# "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
|
local remote_3rd_party_hosts="${1}" # Optional list of hosts to check
|
||||||
|
|
||||||
local remote3rdPartySuccess
|
local remote3rdPartySuccess
|
||||||
local retval
|
local retval
|
||||||
|
@ -1880,9 +1922,12 @@ function CheckConnectivity3rdPartyHosts {
|
||||||
|
|
||||||
if [ "$_PARANOIA_DEBUG" != true ]; then # Do not loose time in paranoia debug #__WITH_PARANOIA_DEBUG
|
if [ "$_PARANOIA_DEBUG" != true ]; then # Do not loose time in paranoia debug #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
if [ "$REMOTE_3RD_PARTY_HOSTS" != "" ]; then
|
if [ "$remote_3rd_party_hosts" == "" ]; then
|
||||||
|
remote_3rd_party_hosts="$REMOTE_3RD_PARTY_HOSTS"
|
||||||
|
fi
|
||||||
|
if [ "$remote_3rd_party_hosts" != "" ]; then
|
||||||
remote3rdPartySuccess=false
|
remote3rdPartySuccess=false
|
||||||
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" &
|
||||||
ExecTasks $! "${FUNCNAME[0]}" false 0 0 60 180 true $SLEEP_TIME $KEEP_LOGGING
|
ExecTasks $! "${FUNCNAME[0]}" false 0 0 60 180 true $SLEEP_TIME $KEEP_LOGGING
|
||||||
|
@ -1891,6 +1936,7 @@ function CheckConnectivity3rdPartyHosts {
|
||||||
Logger "Cannot ping 3rd party host [$i]. Return code [$retval]." "NOTICE"
|
Logger "Cannot ping 3rd party host [$i]. Return code [$retval]." "NOTICE"
|
||||||
else
|
else
|
||||||
remote3rdPartySuccess=true
|
remote3rdPartySuccess=true
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -2493,7 +2539,7 @@ function TrapQuit {
|
||||||
UnlockReplicas
|
UnlockReplicas
|
||||||
RunAfterHook
|
RunAfterHook
|
||||||
Logger "$PROGRAM finished." "ALWAYS"
|
Logger "$PROGRAM finished." "ALWAYS"
|
||||||
if [ $ALWAYS_SEND_MAILS == true ];
|
if [ "$ALWAYS_SEND_MAILS" == true ];
|
||||||
then
|
then
|
||||||
SendAlert
|
SendAlert
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -109,7 +109,7 @@ function TrapQuit {
|
||||||
UnlockReplicas
|
UnlockReplicas
|
||||||
RunAfterHook
|
RunAfterHook
|
||||||
Logger "$PROGRAM finished." "ALWAYS"
|
Logger "$PROGRAM finished." "ALWAYS"
|
||||||
if [ $ALWAYS_SEND_MAILS == true ];
|
if [ "$ALWAYS_SEND_MAILS" == true ];
|
||||||
then
|
then
|
||||||
SendAlert
|
SendAlert
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -17,8 +17,8 @@ INSTANCE_ID="installer-$SCRIPT_BUILD"
|
||||||
## Tested on RHEL / CentOS 6 & 7, Fedora 23, Debian 7 & 8, Mint 17 and FreeBSD 8, 10 and 11
|
## Tested on RHEL / CentOS 6 & 7, Fedora 23, Debian 7 & 8, Mint 17 and FreeBSD 8, 10 and 11
|
||||||
## Please adapt this to fit your distro needs
|
## Please adapt this to fit your distro needs
|
||||||
|
|
||||||
_OFUNCTIONS_VERSION=2.3.0-RC4
|
_OFUNCTIONS_VERSION=2.3.2
|
||||||
_OFUNCTIONS_BUILD=2020111502
|
_OFUNCTIONS_BUILD=2021051801
|
||||||
_OFUNCTIONS_BOOTSTRAP=true
|
_OFUNCTIONS_BOOTSTRAP=true
|
||||||
|
|
||||||
if ! type "$BASH" > /dev/null; then
|
if ! type "$BASH" > /dev/null; then
|
||||||
|
|
55
osync.sh
55
osync.sh
|
@ -13,8 +13,8 @@ IS_STABLE=false
|
||||||
CONFIG_FILE_REVISION_REQUIRED=1.3.0
|
CONFIG_FILE_REVISION_REQUIRED=1.3.0
|
||||||
|
|
||||||
|
|
||||||
_OFUNCTIONS_VERSION=2.3.0-RC4
|
_OFUNCTIONS_VERSION=2.3.2
|
||||||
_OFUNCTIONS_BUILD=2020111502
|
_OFUNCTIONS_BUILD=2021051801
|
||||||
_OFUNCTIONS_BOOTSTRAP=true
|
_OFUNCTIONS_BOOTSTRAP=true
|
||||||
|
|
||||||
if ! type "$BASH" > /dev/null; then
|
if ! type "$BASH" > /dev/null; then
|
||||||
|
@ -1716,6 +1716,41 @@ function RunAfterHook {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function TimeCheck {
|
||||||
|
# Checks if more than deltatime seconds have passed since last check, which is stored in timefile
|
||||||
|
|
||||||
|
local timefile="${1}"
|
||||||
|
local deltatime="${2}"
|
||||||
|
|
||||||
|
if [ -f "$timefile" ]; then
|
||||||
|
result=$(cat "$timefile")
|
||||||
|
tstamp=$(date +%s)
|
||||||
|
if [ $((tstamp-result)) -gt $deltatime ]; then
|
||||||
|
echo "$(date +%s)" > "$timefile"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "$(date +%s)" > "$timefile"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function Ping {
|
||||||
|
# Simple ping check
|
||||||
|
__CheckArguments 1 $# "$@"
|
||||||
|
|
||||||
|
local host="${1}"
|
||||||
|
|
||||||
|
local retval
|
||||||
|
|
||||||
|
eval "$PING_CMD $host > /dev/null 2>&1" &
|
||||||
|
ExecTasks $! "${FUNCNAME[0]}" false 0 0 60 180 true $SLEEP_TIME $KEEP_LOGGING
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function CheckConnectivityRemoteHost {
|
function CheckConnectivityRemoteHost {
|
||||||
|
|
||||||
local retval
|
local retval
|
||||||
|
@ -1733,15 +1768,24 @@ function CheckConnectivityRemoteHost {
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckConnectivity3rdPartyHosts {
|
function CheckConnectivity3rdPartyHosts {
|
||||||
|
# Check if at least one host is reachable in order to diag internet
|
||||||
|
# third_party_hosts_ips=('1.1.1.1' '8.8.8.8' 'kernel.org' 'google.com')
|
||||||
|
# CheckConnectivity3rdPartyHosts $third_party_hosts_ips
|
||||||
|
|
||||||
|
|
||||||
|
local remote_3rd_party_hosts="${1}" # Optional list of hosts to check
|
||||||
|
|
||||||
local remote3rdPartySuccess
|
local remote3rdPartySuccess
|
||||||
local retval
|
local retval
|
||||||
local i
|
local i
|
||||||
|
|
||||||
|
|
||||||
if [ "$REMOTE_3RD_PARTY_HOSTS" != "" ]; then
|
if [ "$remote_3rd_party_hosts" == "" ]; then
|
||||||
|
remote_3rd_party_hosts="$REMOTE_3RD_PARTY_HOSTS"
|
||||||
|
fi
|
||||||
|
if [ "$remote_3rd_party_hosts" != "" ]; then
|
||||||
remote3rdPartySuccess=false
|
remote3rdPartySuccess=false
|
||||||
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" &
|
||||||
ExecTasks $! "${FUNCNAME[0]}" false 0 0 60 180 true $SLEEP_TIME $KEEP_LOGGING
|
ExecTasks $! "${FUNCNAME[0]}" false 0 0 60 180 true $SLEEP_TIME $KEEP_LOGGING
|
||||||
|
@ -1750,6 +1794,7 @@ function CheckConnectivity3rdPartyHosts {
|
||||||
Logger "Cannot ping 3rd party host [$i]. Return code [$retval]." "NOTICE"
|
Logger "Cannot ping 3rd party host [$i]. Return code [$retval]." "NOTICE"
|
||||||
else
|
else
|
||||||
remote3rdPartySuccess=true
|
remote3rdPartySuccess=true
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -2344,7 +2389,7 @@ function TrapQuit {
|
||||||
UnlockReplicas
|
UnlockReplicas
|
||||||
RunAfterHook
|
RunAfterHook
|
||||||
Logger "$PROGRAM finished." "ALWAYS"
|
Logger "$PROGRAM finished." "ALWAYS"
|
||||||
if [ $ALWAYS_SEND_MAILS == true ];
|
if [ "$ALWAYS_SEND_MAILS" == true ];
|
||||||
then
|
then
|
||||||
SendAlert
|
SendAlert
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue