TrapQuit function should exist as subset

This commit is contained in:
root 2020-03-15 22:31:07 +01:00
parent 98c1b97fb0
commit 8788582f63
4 changed files with 29 additions and 56 deletions

View File

@ -3,7 +3,7 @@ SUBPROGRAM=[prgname]
PROGRAM="$SUBPROGRAM-batch" # Batch program to run osync / obackup instances sequentially and rerun failed ones PROGRAM="$SUBPROGRAM-batch" # Batch program to run osync / obackup instances sequentially and rerun failed ones
AUTHOR="(L) 2013-2020 by Orsiris de Jong" AUTHOR="(L) 2013-2020 by Orsiris de Jong"
CONTACT="http://www.netpower.fr - ozy@netpower.fr" CONTACT="http://www.netpower.fr - ozy@netpower.fr"
PROGRAM_BUILD=2019090901 PROGRAM_BUILD=2020031501
## Runs an osync /obackup instance for every conf file found ## Runs an osync /obackup instance for every conf file found
## If an instance fails, run it again if time permits ## If an instance fails, run it again if time permits
@ -38,23 +38,7 @@ fi
include #### Logger SUBSET #### include #### Logger SUBSET ####
include #### CleanUp SUBSET #### include #### CleanUp SUBSET ####
include #### TrapQuit SUBSET ####
function TrapQuit {
local exitcode=0
# Get ERROR / WARN alert flags from subprocesses that call Logger
if [ -f "$RUN_DIR/$PROGRAM.Logger.warn.$SCRIPT_PID.$TSTAMP" ]; then
WARN_ALERT=true
exitcode=2
fi
if [ -f "$RUN_DIR/$PROGRAM.Logger.error.$SCRIPT_PID.$TSTAMP" ]; then
ERROR_ALERT=true
exitcode=1
fi
CleanUp
exit $exitcode
}
function CheckEnvironment { function CheckEnvironment {
## osync / obackup executable full path can be set here if it cannot be found on the system ## osync / obackup executable full path can be set here if it cannot be found on the system

View File

@ -10,7 +10,7 @@ PROGRAM_BINARY=$PROGRAM".sh"
PROGRAM_BATCH=$PROGRAM"-batch.sh" PROGRAM_BATCH=$PROGRAM"-batch.sh"
SSH_FILTER="ssh_filter.sh" SSH_FILTER="ssh_filter.sh"
SCRIPT_BUILD=2020011001 SCRIPT_BUILD=2020031501
INSTANCE_ID="installer-$SCRIPT_BUILD" INSTANCE_ID="installer-$SCRIPT_BUILD"
## osync / obackup / pmocr / zsnap install script ## osync / obackup / pmocr / zsnap install script
@ -39,6 +39,8 @@ fi
include #### UrlEncode SUBSET #### include #### UrlEncode SUBSET ####
include #### GetLocalOS SUBSET #### include #### GetLocalOS SUBSET ####
include #### GetConfFileValue SUBSET #### include #### GetConfFileValue SUBSET ####
include #### CleanUp SUBSET ####
include #### TrapQuit SUBSET ####
function SetLocalOSSettings { function SetLocalOSSettings {
USER=root USER=root
@ -337,23 +339,6 @@ function Usage {
exit 127 exit 127
} }
function TrapQuit {
local exitcode=0
# Get ERROR / WARN alert flags from subprocesses that call Logger
if [ -f "$RUN_DIR/$PROGRAM.Logger.warn.$SCRIPT_PID.$TSTAMP" ]; then
WARN_ALERT=true
exitcode=2
fi
if [ -f "$RUN_DIR/$PROGRAM.Logger.error.$SCRIPT_PID.$TSTAMP" ]; then
ERROR_ALERT=true
exitcode=1
fi
CleanUp
exit $exitcode
}
############################## Script entry point ############################## Script entry point
function GetCommandlineArguments { function GetCommandlineArguments {

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
## MERGE 2019022601 ## MERGE 2020031501
## Merges ofunctions.sh and n_program.sh into program.sh ## Merges ofunctions.sh and n_program.sh into program.sh
## Adds installer ## Adds installer
@ -61,6 +61,7 @@ function __PREPROCESSOR_Constants {
'#### SetConfFileValue SUBSET ####' '#### SetConfFileValue SUBSET ####'
'#### CheckRFC822 SUBSET ####' '#### CheckRFC822 SUBSET ####'
'#### CleanUp SUBSET ####' '#### CleanUp SUBSET ####'
'#### TrapQuit SUBSET ####'
'#### FileMove SUBSET ####' '#### FileMove SUBSET ####'
) )
} }

View File

@ -30,8 +30,8 @@
#### OFUNCTIONS FULL SUBSET #### #### OFUNCTIONS FULL SUBSET ####
#### OFUNCTIONS MINI SUBSET #### #### OFUNCTIONS MINI SUBSET ####
#### OFUNCTIONS MICRO SUBSET #### #### OFUNCTIONS MICRO SUBSET ####
_OFUNCTIONS_VERSION=2.3.0-RC3 _OFUNCTIONS_VERSION=2.3.0-RC4
_OFUNCTIONS_BUILD=2019122501 _OFUNCTIONS_BUILD=2020031501
#### _OFUNCTIONS_BOOTSTRAP SUBSET #### #### _OFUNCTIONS_BOOTSTRAP SUBSET ####
_OFUNCTIONS_BOOTSTRAP=true _OFUNCTIONS_BOOTSTRAP=true
#### _OFUNCTIONS_BOOTSTRAP SUBSET END #### #### _OFUNCTIONS_BOOTSTRAP SUBSET END ####
@ -421,6 +421,26 @@ function KillAllChilds {
return $errorcount return $errorcount
} }
#### TrapQuit SUBSET ####
function GenericTrapQuit {
local exitcode=0
# Get ERROR / WARN alert flags from subprocesses that call Logger
if [ -f "$RUN_DIR/$PROGRAM.Logger.warn.$SCRIPT_PID.$TSTAMP" ]; then
WARN_ALERT=true
exitcode=2
fi
if [ -f "$RUN_DIR/$PROGRAM.Logger.error.$SCRIPT_PID.$TSTAMP" ]; then
ERROR_ALERT=true
exitcode=1
fi
CleanUp
exit $exitcode
}
#### TrapQuit SUBSET END ####
#### CleanUp SUBSET #### #### CleanUp SUBSET ####
function CleanUp { function CleanUp {
# Exit controlmaster before it's socket gets deleted # Exit controlmaster before it's socket gets deleted
@ -442,23 +462,6 @@ function CleanUp {
#### CleanUp SUBSET END #### #### CleanUp SUBSET END ####
function GenericTrapQuit {
local exitcode=0
# Get ERROR / WARN alert flags from subprocesses that call Logger
if [ -f "$RUN_DIR/$PROGRAM.Logger.warn.$SCRIPT_PID.$TSTAMP" ]; then
WARN_ALERT=true
exitcode=2
fi
if [ -f "$RUN_DIR/$PROGRAM.Logger.error.$SCRIPT_PID.$TSTAMP" ]; then
ERROR_ALERT=true
exitcode=1
fi
CleanUp
exit $exitcode
}
#### OFUNCTIONS MICRO SUBSET END #### #### OFUNCTIONS MICRO SUBSET END ####
# osync/obackup/pmocr script specific mail alert function, use SendEmail function for generic mail sending # osync/obackup/pmocr script specific mail alert function, use SendEmail function for generic mail sending