#!/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 [ -r "${warteAufFile}" ] && \ ps aux | \ awk '{print $2" "$(NF)}' | \ grep -q "^\s*$(cat "${warteAufFile}") \(\S*/\)\?doalogwatch\$" && \ exit 0 if [ -d "${warteAufFile%/*}" ]; then echo $$ > "${warteAufFile}" fi [ -r #ETCDIR#/backup.conf ] && \ . #ETCDIR#/backup.conf 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 for id in "${!backups[@]}" do [ -e "#TMPDIR#/${id}.pid" ] && \ warten=true done sleep 1 done fi done logwatch --archives --range "between $(cat "${lmDatei}") and yesterday" echo "${abWannNaechstesMal}" > "${lmDatei}" rm -f ${warteAufFile}