summaryrefslogtreecommitdiff
path: root/doalogwatch.in
blob: ad1d9314927f8f593dca2a2c3f75d6c8a008ee00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash

# doalogwatch, part of logwatch-extra version #VERSION#

abWannNaechstesMal="$(date +%F)"
lmDatei="#CACHEDIR#/logwatch/letzteMeldung"

[ "${abWannNaechstesMal}" == "$(cat "${lmDatei}")" ] && exit 0

warteAufFile="#WAITDIR#/logwatch"
touch ${warteAufFile} || exit 1

[ $(cat /proc/uptime | cut -d ' ' -f 1 | sed "s/\..*\$//") -gt 300 ] || exit 11

# 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
  . #ETCDIR#/backup.conf
  for i in 1 2
  do
    for id in "${!backups[@]}"
    do
      [ -e "#TMPDIR#/${id}.pid" ] && exit 11
    done
    sleep 1
  done
fi

logwatch --archives --range "between $(cat "${lmDatei}") and yesterday" || exit 2

echo "${abWannNaechstesMal}" > "${lmDatei}"

rm -f ${warteAufFile} || exit 1