Skip to content

Instantly share code, notes, and snippets.

@mricon
Created December 10, 2012 15:18
Show Gist options
  • Save mricon/4251184 to your computer and use it in GitHub Desktop.
Save mricon/4251184 to your computer and use it in GitHub Desktop.
Using syslog with snaplock
#!/bin/bash
SNAPLOCK="/mnt/snaplock"
for ZONE in internal dmz frontend; do
YESTERDAY=`date +'%Y/%m/%d' -d 'yesterday'`
TOMORROW=`date +'%Y/%m/%d' -d 'tomorrow'`
LOCKTILL=`date +'%Y%m%d0000' -d '+5 years'`
if [ -d "${SNAPLOCK}/${ZONE}/${YESTERDAY}" ]; then
chmod 0444 ${SNAPLOCK}/${ZONE}/${YESTERDAY}/*
fi
mkdir -p ${SNAPLOCK}/${ZONE}/${TOMORROW}
for FILE in audit secure; do
touch -a -t ${LOCKTILL} ${SNAPLOCK}/${ZONE}/${TOMORROW}/${FILE}.log.gz
chmod 0444 ${SNAPLOCK}/${ZONE}/${TOMORROW}/${FILE}.log.gz
chmod 0644 ${SNAPLOCK}/${ZONE}/${TOMORROW}/${FILE}.log.gz
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment