1#!/bin/sh 2# 3# 4# Perform temporary directory cleaning so that long-lived systems 5# don't end up with excessively old files there. 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_tmps_enable" in 17 [Yy][Ee][Ss]) 18 if [ -z "$daily_clean_tmps_days" ] 19 then 20 echo '$daily_clean_tmps_enable is set but' \ 21 '$daily_clean_tmps_days is not' 22 rc=2 23 else 24 echo "" 25 echo "Removing old temporary files:" 26 27 set -f noglob 28 args="-atime +$daily_clean_tmps_days -mtime +$daily_clean_tmps_days" 29 args="${args} -ctime +$daily_clean_tmps_days" 30 dargs="-empty -mtime +$daily_clean_tmps_days" 31 [ -n "$daily_clean_tmps_ignore" ] && { 32 args="$args "`echo " ${daily_clean_tmps_ignore% }" | 33 sed 's/[ ][ ]*/ ! -name /g'` 34 dargs="$dargs "`echo " ${daily_clean_tmps_ignore% }" | 35 sed 's/[ ][ ]*/ ! -name /g'` 36 } 37 case "$daily_clean_tmps_verbose" in 38 [Yy][Ee][Ss]) 39 print=-print;; 40 *) 41 print=;; 42 esac 43 44 rc=$(for dir in $daily_clean_tmps_dirs 45 do 46 [ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && { 47 find -x -d . -type f $args -delete $print 48 find -x -d . ! -name . -type d $dargs -delete $print 49 } | sed "s,^\\., $dir," 50 done | tee /dev/stderr | wc -l) 51 [ -z "$print" ] && rc=0 52 [ $rc -gt 1 ] && rc=1 53 set -f glob 54 fi;; 55 56 *) rc=0;; 57esac 58 59exit $rc 60