Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / etc / periodic / daily / 150.clean-hoststat
1 #!/bin/sh
2 #
3 # $FreeBSD: src/etc/periodic/daily/150.clean-hoststat,v 1.3.2.2 2000/09/20 02:46:15 jkh Exp $
4 # $DragonFly: src/etc/periodic/daily/150.clean-hoststat,v 1.2 2003/06/17 04:24:48 dillon Exp $
5 #
6 # Remove stale files in /var/spool/.hoststat
7 #
8
9 # If there is a global system configuration file, suck it in.
10 #
11 if [ -r /etc/defaults/periodic.conf ]
12 then
13     . /etc/defaults/periodic.conf
14     source_periodic_confs
15 fi
16
17 case "$daily_clean_hoststat_enable" in
18     [Yy][Ee][Ss])
19         if [ -z "$daily_clean_hoststat_days" ]
20         then
21             echo '$daily_clean_hoststat_enable is enabled but' \
22                 '$daily_clean_hoststat_days is not set'
23             rc=2
24         elif [ ! -d /var/spool/.hoststat ]
25         then
26             echo '$daily_clean_hoststat_enable is enabled but' \
27                 "/var/spool/.hoststat doesn't exist"
28             rc=2
29         else
30             echo ""
31             echo "Removing stale files from /var/spool/.hoststat:"
32
33             case "$daily_clean_hoststat_verbose" in
34                 [Yy][Ee][Ss])
35                     print=-print;;
36                 *)
37                     print=;;
38             esac
39
40             if cd /var/hoststat
41             then
42                 rc=$(find . ! -name . -mtime +$daily_clean_hoststat_days \
43                     -delete $print | tee /dev/stderr | wc -l)
44                 [ -z "$print" ] && rc=0
45                 [ $rc -gt 1 ] && rc=1
46             else
47                 rc=3
48             fi
49         fi;;
50
51     *)  rc=0;;
52 esac
53
54 exit $rc