1997-08-16 17:04:02 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
1999-08-27 23:37:10 +00:00
|
|
|
# $FreeBSD$
|
1997-08-16 17:04:02 +00:00
|
|
|
#
|
2000-06-08 08:48:15 +00:00
|
|
|
# Perform temporary directory cleaning so that long-lived systems
|
2000-06-23 01:18:31 +00:00
|
|
|
# don't end up with excessively old files there.
|
1997-08-16 17:04:02 +00:00
|
|
|
#
|
|
|
|
|
2000-06-08 08:48:15 +00:00
|
|
|
# If there is a global system configuration file, suck it in.
|
|
|
|
#
|
2000-06-23 01:18:31 +00:00
|
|
|
if [ -r /etc/defaults/periodic.conf ]
|
|
|
|
then
|
|
|
|
. /etc/defaults/periodic.conf
|
|
|
|
source_periodic_confs
|
1997-08-16 17:04:02 +00:00
|
|
|
fi
|
|
|
|
|
2000-06-23 01:18:31 +00:00
|
|
|
case "$daily_clean_tmps_enable" in
|
2000-06-08 08:48:15 +00:00
|
|
|
[Yy][Ee][Ss])
|
2000-09-14 17:19:15 +00:00
|
|
|
if [ -z "$daily_clean_tmps_days" ]
|
2000-06-09 17:05:11 +00:00
|
|
|
then
|
2000-09-14 17:19:15 +00:00
|
|
|
echo '$daily_clean_tmps_enable is set but' \
|
|
|
|
'$daily_clean_tmps_days is not'
|
|
|
|
rc=2
|
|
|
|
else
|
2000-06-09 17:05:11 +00:00
|
|
|
echo ""
|
|
|
|
echo "Removing old temporary files:"
|
2000-06-08 08:48:15 +00:00
|
|
|
|
2000-06-09 17:05:11 +00:00
|
|
|
set -f noglob
|
2000-06-23 01:18:31 +00:00
|
|
|
args="-atime +$daily_clean_tmps_days -mtime +$daily_clean_tmps_days"
|
2002-10-06 18:48:20 +00:00
|
|
|
args="${args} -ctime +$daily_clean_tmps_days"
|
2004-02-28 04:58:40 +00:00
|
|
|
dargs="-empty -mtime +$daily_clean_tmps_days"
|
|
|
|
[ -n "$daily_clean_tmps_ignore" ] && {
|
2000-06-23 01:18:31 +00:00
|
|
|
args="$args "`echo " ${daily_clean_tmps_ignore% }" |
|
2000-06-09 17:05:11 +00:00
|
|
|
sed 's/[ ][ ]*/ ! -name /g'`
|
2004-02-28 04:58:40 +00:00
|
|
|
dargs="$dargs "`echo " ${daily_clean_tmps_ignore% }" |
|
|
|
|
sed 's/[ ][ ]*/ ! -name /g'`
|
|
|
|
}
|
2000-06-23 01:18:31 +00:00
|
|
|
case "$daily_clean_tmps_verbose" in
|
2000-06-09 17:05:11 +00:00
|
|
|
[Yy][Ee][Ss])
|
|
|
|
print=-print;;
|
|
|
|
*)
|
|
|
|
print=;;
|
|
|
|
esac
|
2000-06-08 08:48:15 +00:00
|
|
|
|
2000-09-14 17:19:15 +00:00
|
|
|
rc=$(for dir in $daily_clean_tmps_dirs
|
|
|
|
do
|
|
|
|
[ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && {
|
|
|
|
find -d . -type f $args -delete $print
|
2004-02-28 04:58:40 +00:00
|
|
|
find -d . ! -name . -type d $dargs -delete $print
|
2000-09-14 17:19:15 +00:00
|
|
|
} | sed "s,^\\., $dir,"
|
|
|
|
done | tee /dev/stderr | wc -l)
|
|
|
|
[ -z "$print" ] && rc=0
|
|
|
|
[ $rc -gt 1 ] && rc=1
|
2000-06-09 17:05:11 +00:00
|
|
|
set -f glob
|
|
|
|
fi;;
|
2000-09-14 17:19:15 +00:00
|
|
|
|
|
|
|
*) rc=0;;
|
2000-06-08 08:48:15 +00:00
|
|
|
esac
|
2000-09-14 17:19:15 +00:00
|
|
|
|
|
|
|
exit $rc
|