#!/bin/sh
#
# This script cleans up chart images left by the dashboard chart generation
#
# NOTE:  We probably shouldn't run this script as root because it is deleting
#        things. 
#

CHART_DIR='/app/data/charts/dashboard'

# Just a sanity check to make sure we aren't root, I could be a little paranoid
if [ `id -u` = 0 ]; then
    echo "Do not run this program as root" >&2
    exit 1;
fi

# More sanity
if [ -z "$CHART_DIR" ]; then
    echo "CHART_DIR not defined" >&2
    exit 1;
fi

# Extreeme sanity
if [ -z `echo $CHART_DIR | grep "^/"` ]; then
    echo "CHART_DIR is not an absolute path" >&2
    exit 1;
fi


find $CHART_DIR -atime +1 -exec rm {} \;




