1#!/bin/sh
2#
3# $FreeBSD$
4#
5# Remove stale files in /var/rwho
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_rwho_enable" in
17    [Yy][Ee][Ss])
18	if [ -z "$daily_clean_rwho_days" ]
19	then
20	    echo '$daily_clean_rwho_enable is enabled but' \
21		'$daily_clean_rwho_days is not set'
22	    rc=2
23	elif [ ! -d /var/rwho ]
24	then
25	    echo '$daily_clean_rwho_enable is enabled but /var/rwho' \
26		"doesn't exist"
27	    rc=2
28	else
29	    echo ""
30	    echo "Removing stale files from /var/rwho:"
31
32	    case "$daily_clean_rwho_verbose" in
33		[Yy][Ee][Ss])
34		    print=-print;;
35		*)
36		    print=;;
37	    esac
38
39	    if cd /var/rwho
40	    then
41		rc=$(find . ! -name . -mtime +$daily_clean_rwho_days \
42		    -delete $print | tee /dev/stderr | wc -l)
43		[ -z "$print" ] && rc=0
44		[ $rc -gt 1 ] && rc=1
45	    else
46		rc=3
47	    fi
48	fi;;
49
50    *)  rc=0;;
51esac
52
53exit $rc
54