summaryrefslogtreecommitdiffhomepage
path: root/whiteboard-cleanup
blob: 7a987e09ba7fde010c1edea7cca30f698025ffd6 (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
#!/bin/bash
#
# Cleanup global whiteboard files
#
# To be called by cron
#

set -e

# look up config file
CONFIGFILE=/etc/whiteboard.conf
XMLLINTOPTS="--nonet --nocdata --nocatalogs"
DATAPATH=`xmllint --xpath "/config/datapath/text()" $XMLLINTOPTS $CONFIGFILE`
MAXAGE=`xmllint --xpath "/config/maxage/text()" $XMLLINTOPTS $CONFIGFILE`

cd $DATAPATH

ls -1 | while read i ; do
  AGE=$((`date +"%s"` - `stat -c "%Y" $i`))
  if [[ "$AGE" -gt "$MAXAGE" ]] ; then
	  echo "Deleting entry $i ..."
	  rm $i
  fi
done