xref: /freebsd/usr.sbin/periodic/etc/daily/140.clean-rwho (revision f126890ac5386406dadf7c4cfa9566cbb56537c5)
1#!/bin/sh
2#
3#
4# Remove stale files in /var/rwho
5#
6
7# If there is a global system configuration file, suck it in.
8#
9if [ -r /etc/defaults/periodic.conf ]
10then
11    . /etc/defaults/periodic.conf
12    source_periodic_confs
13fi
14
15case "$daily_clean_rwho_enable" in
16    [Yy][Ee][Ss])
17	if [ -z "$daily_clean_rwho_days" ]
18	then
19	    echo '$daily_clean_rwho_enable is enabled but' \
20		'$daily_clean_rwho_days is not set'
21	    rc=2
22	elif [ ! -d /var/rwho ]
23	then
24	    echo '$daily_clean_rwho_enable is enabled but /var/rwho' \
25		"doesn't exist"
26	    rc=2
27	else
28	    echo ""
29	    echo "Removing stale files from /var/rwho:"
30
31	    case "$daily_clean_rwho_verbose" in
32		[Yy][Ee][Ss])
33		    print=-print;;
34		*)
35		    print=;;
36	    esac
37
38	    if cd /var/rwho
39	    then
40		rc=$(find . ! -name . -mtime +$daily_clean_rwho_days \
41		    -delete $print | tee /dev/stderr | wc -l)
42		[ -z "$print" ] && rc=0
43		[ $rc -gt 1 ] && rc=1
44	    else
45		rc=3
46	    fi
47	fi;;
48
49    *)  rc=0;;
50esac
51
52exit $rc
53