@ -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 = 20190 52203
_OFUNCTIONS_BUILD = 20190 70502
_OFUNCTIONS_BOOTSTRAP = true
if ! type " $BASH " > /dev/null; then
@ -92,8 +92,28 @@ if [ "$SLEEP_TIME" == "" ]; then # Leave the possibity to set SLEEP_TIME as envi
SLEEP_TIME = .05
fi
# The variables SCRIPT_PID and TSTAMP needs to be declared as soon as the program begins. The function PoorMansRandomGenerator is needed for TSTAMP (since some systems date function does not give nanoseconds)
SCRIPT_PID = $$
# Get a random number of digits length on Windows BusyBox alike, also works on most Unixes that have dd
function PoorMansRandomGenerator {
local digits = " ${ 1 } " # The number of digits to generate
local number
# Some read bytes can't be used, se we read twice the number of required bytes
dd if = /dev/urandom bs = $digits count = 2 2> /dev/null | while read -r -n1 char; do
number = $number $( printf "%d" " ' $char " )
if [ ${# number } -ge $digits ] ; then
echo ${ number : 0 : $digits }
break;
fi
done
}
# Initial TSTMAP value before function declaration
TSTAMP = $( date '+%Y%m%dT%H%M%S' ) .$( PoorMansRandomGenerator 5)
LOCAL_USER = $( whoami)
LOCAL_HOST = $( hostname)
@ -126,52 +146,10 @@ fi
## If the same program gets remotely executed, add _REMOTE_EXECUTION=true to it's environment so it knows it has to write into a separate directory
## This will thus not affect local $RUN_DIR variables
if [ " $_REMOTE_EXECUTION " = = true ] ; then
mkdir -p " $RUN_DIR / $PROGRAM .remote "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote "
mkdir -p " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
fi
# Get a random number on Windows BusyBox alike, also works on most Unixes that have dd, if dd is not found, then return $RANDOM
function PoorMansRandomGenerator {
local digits = " ${ 1 } " # The number of digits to generate
local number
local isFirst = true
if type dd >/dev/null 2>& 1; then
# Some read bytes can't be used, se we read twice the number of required bytes
dd if = /dev/urandom bs = $digits count = 2 2> /dev/null | while read -r -n1 char; do
if [ $isFirst = = false ] || [ $( printf "%d" " ' $char " ) != "0" ] ; then
number = $number $( printf "%d" " ' $char " )
isFirst = false
fi
if [ ${# number } -ge $digits ] ; then
echo ${ number : 0 : $digits }
break;
fi
done
elif [ " $RANDOM " -ne 0 ] ; then
echo $RANDOM
else
Logger "Cannot generate random number." "ERROR"
fi
}
function PoorMansRandomGenerator {
local digits = " ${ 1 } " # The number of digits to generate
local number
# Some read bytes can't be used, se we read twice the number of required bytes
dd if = /dev/urandom bs = $digits count = 2 2> /dev/null | while read -r -n1 char; do
number = $number $( printf "%d" " ' $char " )
if [ ${# number } -ge $digits ] ; then
echo ${ number : 0 : $digits }
break;
fi
done
}
# Initial TSTMAP value before function declaration
TSTAMP = $( date '+%Y%m%dT%H%M%S' ) .$( PoorMansRandomGenerator 5)
# Default alert attachment filename
ALERT_LOG_FILE = " $RUN_DIR / $PROGRAM . $SCRIPT_PID . $TSTAMP .last.log "
@ -443,6 +421,11 @@ function KillAllChilds {
function CleanUp {
if [ " $_DEBUG " != true ] ; then
# Removing optional remote $RUN_DIR that goes into local $RUN_DIR
if [ -d " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP " ] ; then
rm -rf " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP "
fi
# Removing all temporary run files
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP "
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP .tmp "
@ -2696,8 +2679,8 @@ fi
## If the same program gets remotely executed, add _REMOTE_EXECUTION=true to it's environment so it knows it has to write into a separate directory
## This will thus not affect local $RUN_DIR variables
if [ " $_REMOTE_EXECUTION " = = true ] ; then
mkdir -p " $RUN_DIR / $PROGRAM .remote "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote "
mkdir -p " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
fi
## allow function call checks #__WITH_PARANOIA_DEBUG
if [ " $_PARANOIA_DEBUG " = = true ] ; then #__WITH_PARANOIA_DEBUG
@ -2871,6 +2854,11 @@ function RemoteLogger {
}
function CleanUp {
if [ " $_DEBUG " != true ] ; then
# Removing optional remote $RUN_DIR that goes into local $RUN_DIR
if [ -d " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP " ] ; then
rm -rf " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP "
fi
# Removing all temporary run files
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP "
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP .tmp "
@ -3080,8 +3068,8 @@ fi
## If the same program gets remotely executed, add _REMOTE_EXECUTION=true to it's environment so it knows it has to write into a separate directory
## This will thus not affect local $RUN_DIR variables
if [ " $_REMOTE_EXECUTION " = = true ] ; then
mkdir -p " $RUN_DIR / $PROGRAM .remote "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote "
mkdir -p " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
fi
## allow function call checks #__WITH_PARANOIA_DEBUG
if [ " $_PARANOIA_DEBUG " = = true ] ; then #__WITH_PARANOIA_DEBUG
@ -3243,6 +3231,11 @@ function RemoteLogger {
}
function CleanUp {
if [ " $_DEBUG " != true ] ; then
# Removing optional remote $RUN_DIR that goes into local $RUN_DIR
if [ -d " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP " ] ; then
rm -rf " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP "
fi
# Removing all temporary run files
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP "
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP .tmp "
@ -3685,8 +3678,8 @@ fi
## If the same program gets remotely executed, add _REMOTE_EXECUTION=true to it's environment so it knows it has to write into a separate directory
## This will thus not affect local $RUN_DIR variables
if [ " $_REMOTE_EXECUTION " = = true ] ; then
mkdir -p " $RUN_DIR / $PROGRAM .remote "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote "
mkdir -p " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
fi
## allow function call checks #__WITH_PARANOIA_DEBUG
if [ " $_PARANOIA_DEBUG " = = true ] ; then #__WITH_PARANOIA_DEBUG
@ -3860,6 +3853,11 @@ function RemoteLogger {
}
function CleanUp {
if [ " $_DEBUG " != true ] ; then
# Removing optional remote $RUN_DIR that goes into local $RUN_DIR
if [ -d " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP " ] ; then
rm -rf " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP "
fi
# Removing all temporary run files
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP "
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP .tmp "
@ -4390,8 +4388,8 @@ fi
## If the same program gets remotely executed, add _REMOTE_EXECUTION=true to it's environment so it knows it has to write into a separate directory
## This will thus not affect local $RUN_DIR variables
if [ " $_REMOTE_EXECUTION " = = true ] ; then
mkdir -p " $RUN_DIR / $PROGRAM .remote "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote "
mkdir -p " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
fi
## allow function call checks #__WITH_PARANOIA_DEBUG
if [ " $_PARANOIA_DEBUG " = = true ] ; then #__WITH_PARANOIA_DEBUG
@ -4516,6 +4514,11 @@ function RemoteLogger {
}
function CleanUp {
if [ " $_DEBUG " != true ] ; then
# Removing optional remote $RUN_DIR that goes into local $RUN_DIR
if [ -d " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP " ] ; then
rm -rf " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP "
fi
# Removing all temporary run files
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP "
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP .tmp "
@ -5322,8 +5325,8 @@ fi
## If the same program gets remotely executed, add _REMOTE_EXECUTION=true to it's environment so it knows it has to write into a separate directory
## This will thus not affect local $RUN_DIR variables
if [ " $_REMOTE_EXECUTION " = = true ] ; then
mkdir -p " $RUN_DIR / $PROGRAM .remote "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote "
mkdir -p " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
fi
## allow function call checks #__WITH_PARANOIA_DEBUG
if [ " $_PARANOIA_DEBUG " = = true ] ; then #__WITH_PARANOIA_DEBUG
@ -5497,6 +5500,11 @@ function RemoteLogger {
}
function CleanUp {
if [ " $_DEBUG " != true ] ; then
# Removing optional remote $RUN_DIR that goes into local $RUN_DIR
if [ -d " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP " ] ; then
rm -rf " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP "
fi
# Removing all temporary run files
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP "
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP .tmp "
@ -5651,8 +5659,8 @@ fi
## If the same program gets remotely executed, add _REMOTE_EXECUTION=true to it's environment so it knows it has to write into a separate directory
## This will thus not affect local $RUN_DIR variables
if [ " $_REMOTE_EXECUTION " = = true ] ; then
mkdir -p " $RUN_DIR / $PROGRAM .remote "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote "
mkdir -p " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
RUN_DIR = " $RUN_DIR / $PROGRAM .remote .$SCRIPT_PID . $TSTAMP "
fi
## allow function call checks #__WITH_PARANOIA_DEBUG
if [ " $_PARANOIA_DEBUG " = = true ] ; then #__WITH_PARANOIA_DEBUG
@ -5777,6 +5785,11 @@ function RemoteLogger {
}
function CleanUp {
if [ " $_DEBUG " != true ] ; then
# Removing optional remote $RUN_DIR that goes into local $RUN_DIR
if [ -d " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP " ] ; then
rm -rf " $RUN_DIR / $PROGRAM .remote. $SCRIPT_PID . $TSTAMP "
fi
# Removing all temporary run files
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP "
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
rm -f " $RUN_DIR / $PROGRAM . " *" . $SCRIPT_PID . $TSTAMP .tmp "