Added an option to run after exec cmds on error

pull/50/head
deajan 8 years ago
parent d6e543f1d6
commit d52b6dd5e6

@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2016 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION=1.1-pre
PROGRAM_BUILD=2016040603
PROGRAM_BUILD=2016040604
IS_STABLE=yes
## FUNC_BUILD=2016040602
@ -1087,6 +1087,9 @@ function TrapQuit {
else
Logger "Debug mode, no alert mail will be sent." "NOTICE"
fi
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
RunAfterHook
fi
CleanUp
Logger "$PROGRAM finished with errors." "ERROR"
exitcode=1
@ -1098,11 +1101,17 @@ function TrapQuit {
else
Logger "Debug mode, no alert mail will be sent." "NOTICE"
fi
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
RunAfterHook
fi
CleanUp
Logger "$PROGRAM finished with warnings." "WARN"
exitcode=240 # Special exit code for daemon mode not stopping on warnings
else
UnlockReplicas
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
RunAfterHook
fi
CleanUp
Logger "$PROGRAM finished." "NOTICE"
exitcode=0

@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2016 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION=1.1-pre
PROGRAM_BUILD=2016040603
PROGRAM_BUILD=2016040604
IS_STABLE=yes
source "./ofunctions.sh"
@ -38,6 +38,9 @@ function TrapQuit {
else
Logger "Debug mode, no alert mail will be sent." "NOTICE"
fi
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
RunAfterHook
fi
CleanUp
Logger "$PROGRAM finished with errors." "ERROR"
exitcode=1
@ -49,11 +52,17 @@ function TrapQuit {
else
Logger "Debug mode, no alert mail will be sent." "NOTICE"
fi
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
RunAfterHook
fi
CleanUp
Logger "$PROGRAM finished with warnings." "WARN"
exitcode=240 # Special exit code for daemon mode not stopping on warnings
else
UnlockReplicas
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
RunAfterHook
fi
CleanUp
Logger "$PROGRAM finished." "NOTICE"
exitcode=0

@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2016 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION=1.1-pre
PROGRAM_BUILD=2016040603
PROGRAM_BUILD=2016040604
IS_STABLE=yes
## FUNC_BUILD=2016040602
@ -1015,6 +1015,9 @@ function TrapQuit {
else
Logger "Debug mode, no alert mail will be sent." "NOTICE"
fi
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
RunAfterHook
fi
CleanUp
Logger "$PROGRAM finished with errors." "ERROR"
exitcode=1
@ -1026,11 +1029,17 @@ function TrapQuit {
else
Logger "Debug mode, no alert mail will be sent." "NOTICE"
fi
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
RunAfterHook
fi
CleanUp
Logger "$PROGRAM finished with warnings." "WARN"
exitcode=240 # Special exit code for daemon mode not stopping on warnings
else
UnlockReplicas
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then
RunAfterHook
fi
CleanUp
Logger "$PROGRAM finished." "NOTICE"
exitcode=0

@ -2,7 +2,7 @@
###### Osync - Rsync based two way sync engine with fault tolerance
###### (C) 2013-2015 by Orsiris "Ozy" de Jong (www.netpower.fr)
###### Config file rev 2016032901
###### Config file rev 2016040601
## ---------- GENERAL OPTIONS
@ -161,3 +161,6 @@ MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops Osync execution if one of the above commands fail
STOP_ON_CMD_ERROR=yes
## Run local and remote after sync commands even on failure
RUN_AFTER_CMD_ON_ERROR=no

@ -6,7 +6,7 @@ AUTHOR="(C) 2015 by Orsiris \"Ozy\" de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
OLD_PROGRAM_VERSION="1.0x"
NEW_PROGRAM_VERSION="v1.1x"
PROGRAM_BUILD=2016033102
PROGRAM_BUILD=2016040601
function Init {
OSYNC_DIR=".osync_workdir"
@ -360,6 +360,11 @@ function RewriteConfigFiles {
if ! grep "^DELTA_COPIES=" "$config_file" > /dev/null; then
sed -i '/^PARTIAL=*/a DELTA_COPIES=yes' "$config_file"
fi
if ! grep "^RUN_AFTER_CMD_ON_ERROR=" "$config_file" > /dev/null; then
sed -i '/^STOP_ON_CMD_ERROR=*/a RUN_AFTER_CMD_ON_ERROR=no' "$config_file"
fi
}
_QUICKSYNC=0

Loading…
Cancel
Save