[firewall-logrotate-script] postcript du logrotate des logs de connections.

Ignore-this: 283bad5772c291a53e0c635618157f08

darcs-hash:20111118020126-3a55a-6e4340674890684bd775cd0d5930801cd757ea8a.gz
This commit is contained in:
Valentin Samir 2011-11-18 03:01:26 +01:00
parent f08476b6f8
commit a27e3da685

View file

@ -0,0 +1,28 @@
#!/bin/zsh
umask 0177
if [[ `hostname` == 'komaz' ]]; then
logs_src=/var/log/firewall/
else
exit 41
fi
logs_dst="/home/squid/`hostname`/logs"
if [ ! -d "$logs_dst" ]; then
echo "Destination des logs inexistante"
exit 42
fi
while ( ls -tr "$logs_src" | grep -E 'logall\.log\.[0-9]+\..z2?' ); do
dernier_fichier=$logs_src/$(ls -tr "$logs_src" | grep -E 'logall\.log\.[0-9]+\..z2?' | head -1)
timestamp=$(bzcat "$dernier_fichier" | head -1 | awk '{print $1}')
date=$(date -d "1970-01-01 $timestamp sec" +"%Y-%m-%d")
echo install -o root -g root -m 400 "$dernier_fichier" "$logs_dst/logall.log.$date.bz2"
echo rm "$dernier_fichier"
install -o root -g root -m 400 "$dernier_fichier" "$logs_dst/logall.log.$date.bz2"
rm "$dernier_fichier"
done
#find "$logs_dst" -mtime +365 -delete