From 7452af237b00b10c82cff0e5962357181690a912 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 30 Mar 2020 22:37:14 +0200 Subject: additionalWatchHook -> additionalWatchHookSlow, additionalWatchHookFast --- shutdownasap.conf.in | 13 +++++++++---- shutdownasap.in | 10 +++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/shutdownasap.conf.in b/shutdownasap.conf.in index 7558407..d42892c 100755 --- a/shutdownasap.conf.in +++ b/shutdownasap.conf.in @@ -30,10 +30,9 @@ beforeWatchHook() { true } -# hook to execute if we believe, the system should come down -# If this hook returns with 0, everything is ok - if it returns with 1, -# we should keep waiting for shutdown (and ask this hook again). -additionalWatchHook() { +# This hook should return != 0, if we should keep waiting for shutdown. +# Note, that it is queried often. +additionalWatchHookFast() { if command -v check-if-bareos-backup-is-running; then if ! sudo check-if-bareos-backup-is-running; then return 1 @@ -44,6 +43,12 @@ additionalWatchHook() { return 0 } +# This hook should return != 0, if we should keep waiting for shutdown. +# Note, that it is queried seldom (e.g. once, if it returns 0). +additionalWatchHookSlow() { + return 0 +} + # hook to execute before shutting down beforeShutDownHook() { if command -v doalogwatch >/dev/null; then diff --git a/shutdownasap.in b/shutdownasap.in index 1206fb5..146725a 100755 --- a/shutdownasap.in +++ b/shutdownasap.in @@ -21,7 +21,7 @@ fi beforeWatchHook i=1 -while [ ${i} -gt 0 ] || ! additionalWatchHook +while [ ${i} -gt 0 ] || ! additionalWatchHookSlow do if [ ${i} -eq 0 ] then @@ -84,6 +84,14 @@ do fi done + if ! additionalWatchHookFast + then + nochwarten=true + if ! ${quiet}; then + echo "additionalWatchHookFast" + fi + fi + if ${nochwarten} then if ! ${quiet}; then -- cgit v1.2.3-54-g00ecf