mirror of
https://github.com/deajan/obackup.git
synced 2024-11-15 04:03:41 +01:00
Update ofunctions
This commit is contained in:
parent
acb27bef1b
commit
6b5f819b17
@ -31,7 +31,7 @@
|
|||||||
#### OFUNCTIONS MINI SUBSET ####
|
#### OFUNCTIONS MINI SUBSET ####
|
||||||
#### OFUNCTIONS MICRO SUBSET ####
|
#### OFUNCTIONS MICRO SUBSET ####
|
||||||
_OFUNCTIONS_VERSION=2.3.0-RC2
|
_OFUNCTIONS_VERSION=2.3.0-RC2
|
||||||
_OFUNCTIONS_BUILD=2018110502
|
_OFUNCTIONS_BUILD=2018122103
|
||||||
#### _OFUNCTIONS_BOOTSTRAP SUBSET ####
|
#### _OFUNCTIONS_BOOTSTRAP SUBSET ####
|
||||||
_OFUNCTIONS_BOOTSTRAP=true
|
_OFUNCTIONS_BOOTSTRAP=true
|
||||||
#### _OFUNCTIONS_BOOTSTRAP SUBSET END ####
|
#### _OFUNCTIONS_BOOTSTRAP SUBSET END ####
|
||||||
@ -741,9 +741,11 @@ function TrapError {
|
|||||||
|
|
||||||
function LoadConfigFile {
|
function LoadConfigFile {
|
||||||
local configFile="${1}"
|
local configFile="${1}"
|
||||||
|
local revisionRequired="${2}"
|
||||||
|
|
||||||
__CheckArguments 1 $# "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 1 $# "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
|
local revisionPresent
|
||||||
|
|
||||||
if [ ! -f "$configFile" ]; then
|
if [ ! -f "$configFile" ]; then
|
||||||
Logger "Cannot load configuration file [$configFile]. Cannot start." "CRITICAL"
|
Logger "Cannot load configuration file [$configFile]. Cannot start." "CRITICAL"
|
||||||
@ -752,6 +754,16 @@ function LoadConfigFile {
|
|||||||
Logger "Wrong configuration file supplied [$configFile]. Cannot start." "CRITICAL"
|
Logger "Wrong configuration file supplied [$configFile]. Cannot start." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
revisionPresent=$(GetConfFileValue "$configFile" "CONFIG_FILE_REVISION" true)
|
||||||
|
if [ "$(IsNumeric $revisionPresent)" -eq 0 ]; then
|
||||||
|
revisionPresent=0
|
||||||
|
fi
|
||||||
|
if [ "$revisionRequired" != "" ]; then
|
||||||
|
if [ $(VerComp "$revisionPresent" "$revisionRequired") -eq 2 ]; then
|
||||||
|
Logger "Configuration file seems out of date. Required version [$revisionRequired]. Actual version [$revisionPresent]." "CRITICAL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
# Remove everything that is not a variable assignation
|
# Remove everything that is not a variable assignation
|
||||||
grep '^[^ ]*=[^;&]*' "$configFile" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP"
|
grep '^[^ ]*=[^;&]*' "$configFile" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP"
|
||||||
source "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP"
|
source "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP"
|
||||||
@ -908,7 +920,8 @@ function ExecTasks {
|
|||||||
local commandsConditionArray=() # Array containing conditional commands
|
local commandsConditionArray=() # Array containing conditional commands
|
||||||
local currentCommand # Variable containing currently processed command
|
local currentCommand # Variable containing currently processed command
|
||||||
local currentCommandCondition # Variable containing currently processed conditional command
|
local currentCommandCondition # Variable containing currently processed conditional command
|
||||||
local commandsArrayPid=() # Array containing pids of commands currently run
|
local commandsArrayPid=() # Array containing commands indexed by pids
|
||||||
|
local commandsArrayOutput=() # Array contining command results indexed by pids
|
||||||
local postponedRetryCount=0 # Number of current postponed commands retries
|
local postponedRetryCount=0 # Number of current postponed commands retries
|
||||||
local postponedItemCount=0 # Number of commands that have been postponed (keep at least one in order to check once)
|
local postponedItemCount=0 # Number of commands that have been postponed (keep at least one in order to check once)
|
||||||
local postponedCounter=0
|
local postponedCounter=0
|
||||||
@ -937,8 +950,9 @@ function ExecTasks {
|
|||||||
local executeCommand # Boolean to check if currentCommand can be executed given a condition
|
local executeCommand # Boolean to check if currentCommand can be executed given a condition
|
||||||
local hasPids=false # Are any valable pids given to function ? #__WITH_PARANOIA_DEBUG
|
local hasPids=false # Are any valable pids given to function ? #__WITH_PARANOIA_DEBUG
|
||||||
local functionMode
|
local functionMode
|
||||||
local softAlert=false
|
local softAlert=false # Does a soft alert need to be triggered, if yes, send an alert once
|
||||||
local failedPidsList # List containing failed pids with exit code separated by semicolons (eg : 2355:1;4534:2;2354:3)
|
local failedPidsList # List containing failed pids with exit code separated by semicolons (eg : 2355:1;4534:2;2354:3)
|
||||||
|
local randomOutputName # Random filename for command outputs
|
||||||
|
|
||||||
# Initialise global variable
|
# Initialise global variable
|
||||||
eval "WAIT_FOR_TASK_COMPLETION_$id=\"\""
|
eval "WAIT_FOR_TASK_COMPLETION_$id=\"\""
|
||||||
@ -1103,6 +1117,9 @@ function ExecTasks {
|
|||||||
if [ "$functionMode" == "ParallelExec" ]; then
|
if [ "$functionMode" == "ParallelExec" ]; then
|
||||||
Logger "Command was [${commandsArrayPid[$pid]}]." "ERROR"
|
Logger "Command was [${commandsArrayPid[$pid]}]." "ERROR"
|
||||||
fi
|
fi
|
||||||
|
if [ -f "${commandsArrayOutput[$pid]}" ]; then
|
||||||
|
Logger "Command output was [\$(cat ${commandsArrayOutput[$pid]})\n]." "ERROR"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
errorcount=$((errorcount+1))
|
errorcount=$((errorcount+1))
|
||||||
# Welcome to variable variable bash hell
|
# Welcome to variable variable bash hell
|
||||||
@ -1246,10 +1263,12 @@ function ExecTasks {
|
|||||||
|
|
||||||
if [ $executeCommand == true ]; then
|
if [ $executeCommand == true ]; then
|
||||||
Logger "Running command [$currentCommand]." "DEBUG"
|
Logger "Running command [$currentCommand]." "DEBUG"
|
||||||
eval "$currentCommand" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$id.$SCRIPT_PID.$TSTAMP" 2>&1 &
|
randomOutputName=$(date '+%Y%m%dT%H%M%S').$(PoorMansRandomGenerator 5)
|
||||||
|
eval "$currentCommand" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$randomOutputName.$SCRIPT_PID.$TSTAMP" 2>&1 &
|
||||||
pid=$!
|
pid=$!
|
||||||
pidsArray+=($pid)
|
pidsArray+=($pid)
|
||||||
commandsArrayPid[$pid]="$currentCommand"
|
commandsArrayPid[$pid]="$currentCommand"
|
||||||
|
commandsArrayOutput[$pid]="$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$randomOutputName.$SCRIPT_PID.$TSTAMP"
|
||||||
# Initialize pid execution time array
|
# Initialize pid execution time array
|
||||||
pidsTimeArray[$pid]=0
|
pidsTimeArray[$pid]=0
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user