blob: f3b312db18fe512dbd8fd993633f3bbfc647c46c (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#!/bin/bash
# doalogwatch, part of logwatch-extra version #VERSION#
set -e
abWannNaechstesMal="$(date +%F)"
lmDatei="#CACHEDIR#/logwatch/letzteMeldung"
warteAufFile="#WAITDIR#/logwatch"
[ ! -r "${lmDatei}" ] && \
echo '1970-01-01' > "${lmDatei}"
[ "${abWannNaechstesMal}" == "$(cat "${lmDatei}")" ] && \
exit 0
if [ -r '#ETCDIR#/logwatch/conf/logwatch.conf' ]; then
services=$(
sed -n '
s/^#\s*doalogwatch\s*#\s*Service\s*=\s*//
T
s/^\(["'"'"']\)\(.*\)\1$/\2/
s/^/--service=/
p
' '#ETCDIR#/logwatch/conf/logwatch.conf'
)
fi
if [ -z "${services%%--service=-*}" ]; then
services="--service=All ${services}"
fi
[ -r "${warteAufFile}" ] && \
kill -0 $(cat "${warteAufFile}") 2>/dev/null && \
exit 0
if [ -d "${warteAufFile%/*}" ]; then
echo $$ > "${warteAufFile}"
fi
[ -r '#ETCDIR#/backup.conf' ] && \
. '#ETCDIR#/backup.conf'
warten=true
while ${warten} && [ "$(date '+%H')" != '23' ]; do
warten=false
[ $(sed 's/[. ].*$//' /proc/uptime) -le 300 ] && \
warten=true
# check for currently running backups
ppid=$(awk '$1 == "PPid:" {print $2}' /proc/$$/status)
if [ ! "$(tr '\0' ' ' <"/proc/${ppid}/cmdline")" = '/bin/bash /usr/bin/shutdownasap -q ' ]; then
pgrep -xf "(#BINDIR#/)?backup( .*)?" >/dev/null && \
warten=true
if [ -r '#ETCDIR#/backup.conf' ]; then
for i in 1 2; do
for id in "${!backups[@]}"; do
[ -s "#TMPDIR#/${id}.pid" ] && \
kill -0 $(cat "#TMPDIR#/${id}.pid") 2>/dev/null && \
warten=true
done
sleep 1
done
fi
fi
done
logwatch \
--archives \
--range "between $(cat "${lmDatei}") and yesterday" \
${services}
echo "${abWannNaechstesMal}" > "${lmDatei}"
rm -f ${warteAufFile}
|