summaryrefslogtreecommitdiff
path: root/doalogwatch.in
diff options
context:
space:
mode:
Diffstat (limited to 'doalogwatch.in')
-rwxr-xr-xdoalogwatch.in61
1 files changed, 41 insertions, 20 deletions
diff --git a/doalogwatch.in b/doalogwatch.in
index b9366b0..5813071 100755
--- a/doalogwatch.in
+++ b/doalogwatch.in
@@ -2,38 +2,59 @@
# doalogwatch, part of logwatch-extra version #VERSION#
+set -e
+
abWannNaechstesMal="$(date +%F)"
lmDatei="#CACHEDIR#/logwatch/letzteMeldung"
+warteAufFile="#WAITDIR#/logwatch"
-if ! [ -r "${lmDatei}" ]
-then
+[ ! -r "${lmDatei}" ] && \
echo '1970-01-01' > "${lmDatei}"
-fi
-[ "${abWannNaechstesMal}" == "$(cat "${lmDatei}")" ] && exit 0
+[ "${abWannNaechstesMal}" == "$(cat "${lmDatei}")" ] && \
+ exit 0
-warteAufFile="#WAITDIR#/logwatch"
-touch ${warteAufFile} || exit 1
+[ -r "${warteAufFile}" ] && \
+ ps aux | \
+ grep -q "^\S\+\s\+$(cat "${warteAufFile}")\s" && \
+ exit 0
-[ $(cat /proc/uptime | cut -d ' ' -f 1 | sed "s/\..*\$//") -gt 300 ] || exit 11
+echo $$ > "${warteAufFile}"
-# check for currently running backups
-ps aux | grep -v "\sgrep\s" | grep -q "\s\(#BINDIR#/\)\?backup\s" && exit 11
-if [ -r #ETCDIR#/backup.conf ]
-then
+[ -r #ETCDIR#/backup.conf ] && \
. #ETCDIR#/backup.conf
- for i in 1 2
- do
- for id in "${!backups[@]}"
+
+warten=true
+until ! ${warten}
+do
+
+ warten=false
+
+ [ $(cat /proc/uptime | cut -d ' ' -f 1 | sed "s/\..*\$//") -le 300 ] && \
+ warten=true
+
+ # check for currently running backups
+ ps aux | \
+ grep -v "\sgrep\s" | \
+ grep -q "\s\(#BINDIR#/\)\?backup\s" && \
+ warten=true
+ if [ -r #ETCDIR#/backup.conf ]
+ then
+ for i in 1 2
do
- [ -e "#TMPDIR#/${id}.pid" ] && exit 11
+ for id in "${!backups[@]}"
+ do
+ [ -e "#TMPDIR#/${id}.pid" ] && \
+ warten=true
+ done
+ sleep 1
done
- sleep 1
- done
-fi
+ fi
+
+done
-logwatch --archives --range "between $(cat "${lmDatei}") and yesterday" || exit 2
+logwatch --archives --range "between $(cat "${lmDatei}") and yesterday"
echo "${abWannNaechstesMal}" > "${lmDatei}"
-rm -f ${warteAufFile} || exit 1
+rm -f ${warteAufFile}