100.clean-disks revision 66218
1#!/bin/sh
2#
3# $FreeBSD: head/etc/periodic/daily/100.clean-disks 66218 2000-09-22 06:54:28Z brian $
4#
5# Remove garbage files more than $daily_clean_disks_days days old
6#
7
8# If there is a global system configuration file, suck it in.
9#
10if [ -r /etc/defaults/periodic.conf ]
11then
12    . /etc/defaults/periodic.conf
13    source_periodic_confs
14fi
15
16case "$daily_clean_disks_enable" in
17    [Yy][Ee][Ss])
18	if [ -z "$daily_clean_disks_days" ]
19	then
20	    echo '$daily_clean_disks_enable is set but' \
21		'$daily_clean_disks_days is not'
22	    rc=2
23	elif [ -z "$daily_clean_disks_files" ]
24	then
25	    echo '$daily_clean_disks_enable is set but' \
26		'$daily_clean_disks_files is not'
27	    rc=2
28	else
29	    echo ""
30	    echo "Removing old temporary files:"
31	    set -f noglob
32	    args="$args "`echo " ${daily_clean_disks_files% }" |
33		sed 's/[ 	][ 	]*/ -name /g'`
34
35	    case "$daily_clean_tmps_verbose" in
36		[Yy][Ee][Ss])
37		    print=-print;;
38		*)
39		    print=;;
40	    esac
41
42	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
43		\( $args \) -atime +$daily_clean_disks_days -delete $print |
44		tee /dev/stderr | wc -l)
45	    [ -z "$print" ] && rc=0
46	    [ $rc -gt 1 ] && rc=1
47	    set -f glob
48	fi;;
49
50    *)  rc=0;;
51esac
52
53exit $rc
54