burp_check_age: initial commit
This commit is contained in:
41
check_burp_age.sh
Executable file
41
check_burp_age.sh
Executable file
@@ -0,0 +1,41 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
# param IN: csv file containing userdir,useremail,maxageofbackup in days
|
||||||
|
# ex: /srv/burp/cafeine:thomas@foobar.org:4
|
||||||
|
not_found=1
|
||||||
|
too_old=2
|
||||||
|
|
||||||
|
list=$1
|
||||||
|
if [ ! -r $list ] ; then
|
||||||
|
echo "gimme a csv file"
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
|
||||||
|
function mail_error {
|
||||||
|
user=$1
|
||||||
|
code=$2
|
||||||
|
fileage=$3
|
||||||
|
case $code in
|
||||||
|
($not_found):
|
||||||
|
echo "timestamp file for $user not found or not readable" | mail -s "backup error" rscj@opendoor.fr
|
||||||
|
exit $code
|
||||||
|
;;
|
||||||
|
($too_old):
|
||||||
|
echo -e "Pas de sauvegarde depuis $fileage jours.\n\nPensez a laisser votre pc connecte entre midi et 2, ou lancez une sauvegarde manuelle." | mail -s "Pb de sauvegarde" $user
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
IFS=\;
|
||||||
|
while read userdir mail maxage ; do
|
||||||
|
if [[ $userdir =~ ^# ]] ; then continue ; fi
|
||||||
|
timestampfile=${userdir}/current/timestamp
|
||||||
|
let "maxage=$maxage*86400"
|
||||||
|
test -r $timestampfile || { mail_error $mail $not_found ; continue ; }
|
||||||
|
|
||||||
|
fileage=$( stat -c '%Y' $timestampfile)
|
||||||
|
now=$(date "+%s")
|
||||||
|
let "delta=$now-$fileage"
|
||||||
|
if [ $delta -gt $maxage ] ; then
|
||||||
|
echo $mail $too_old $(($delta/86400))
|
||||||
|
fi
|
||||||
|
done < $1
|
||||||
Reference in New Issue
Block a user