summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-05-24 06:39:18 +0200
committerErich Eckner <git@eckner.net>2016-05-24 06:39:18 +0200
commita5310cc507e7b1b333ac01ede0e9734747855705 (patch)
tree628c6d8ac1d3f6ef50896acbc755f330dc102174
parentf094b0f481990328e08ece8810ac34305dce2ae7 (diff)
downloadlogwatch-extra-a5310cc507e7b1b333ac01ede0e9734747855705.tar.xz
doalogwatch verlässt sich jetzt weniger auf cron und wartet selbst
-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}