archive-expinfo.in 758 Bytes
Newer Older
1 2 3
#!/bin/sh

THRESHOLD=1000
4
DOIT=0
5 6 7 8 9 10 11 12 13 14 15 16 17 18

if [ "$1" = "-t" ] && [ $# -eq 2 ] && [ "$2" -gt 0 ]; then
    THRESHOLD="$2"
elif [ $# -ne 0 ]; then
    cat >&2 <<-EOF
	Usage:
	    $0 [-t threshold]
	EOF
    exit 1
fi

find @prefix@/expinfo -depth 4 -name activity.log -mtime +"$THRESHOLD" \
        -print | sed 's/.activity.log$//' | \
    ( while read DIRNAME; do
19 20 21 22 23 24 25 26 27 28
        if [ $DOIT -ne 0 ]; then
            echo -n "Compressing $DIRNAME... "
            tar cy -C "$DIRNAME/.." -f "${DIRNAME}.tar.bz2" \
                    `basename "$DIRNAME"` && \
                chown `stat -f %u "$DIRNAME"` "${DIRNAME}.tar.bz2" && \
                rm -rf "$DIRNAME"
            echo done
        else
            echo -n "Would compress $DIRNAME... "
        fi
29
      done )