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