From owner-freebsd-bugs Mon Mar 4 12:20:47 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 410CC37B419 for ; Mon, 4 Mar 2002 12:20:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g24KK1g77153; Mon, 4 Mar 2002 12:20:01 -0800 (PST) (envelope-from gnats) Received: from breg.mc.mpls.visi.com (breg.mc.mpls.visi.com [208.42.156.101]) by hub.freebsd.org (Postfix) with ESMTP id A010737B402 for ; Mon, 4 Mar 2002 12:11:57 -0800 (PST) Received: from sheol.localdomain (hawkeyd-fw.dsl.visi.com [208.42.101.193]) by breg.mc.mpls.visi.com (Postfix) with ESMTP id 4B3272D049B; Mon, 4 Mar 2002 14:11:56 -0600 (CST) Received: (from hawkeyd@localhost) by sheol.localdomain (8.11.6/8.11.6) id g24KBsv55481; Mon, 4 Mar 2002 14:11:54 -0600 (CST) (envelope-from hawkeyd) Message-Id: <200203042011.g24KBsv55481@sheol.localdomain> Date: Mon, 4 Mar 2002 14:11:54 -0600 (CST) From: D J Hawkey Jr Reply-To: D J Hawkey Jr To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: conf/35545: Enhanced periodic scripts Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 35545 >Category: conf >Synopsis: Enhanced periodic scripts >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 04 12:20:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: David J Hawkey Jr \ >Release: FreeBSD 4.5-RELEASE i386 >Organization: if (!FIFO) if (!LIFO) break; >Environment: System: FreeBSD sheol.localdomain 4.5-RELEASE FreeBSD 4.5-RELEASE #2: Mon Feb 11 09:18:49 CST 2002 root@sheol.localdomain:/usr/src/sys/compile/SHEOL i386 >Description: /etc/periodic/daily/100.clean-disks should have "exclude paths". /etc/periodic/daily/110.clean-tmps removes empty directories, and should not, IMHO. >How-To-Repeat: Enable either in /etc/periodic.conf >Fix: These two patches. The first, for 100.clean-disks, honors a new variable, daily_clean_disks_excludes (ex., "*/home/*"). The second, for 110.clean-tmps, honors a new variable, daily_clean_tmps_prune (ex., "YES" or "NO"). Additionally, they both actually make their *_verbose variables do the Right Thing(tm), and could pro'lly be applied to many more of the periodic scripts. They both should be scrutinized for correctness. They test out fine here, and fulfill my needs, but may not be generic enough, and I may be blind to some nuances of 'find' and/or 'periodic'. --- 100.clean-disks.orig Mon Jan 28 07:13:17 2002 +++ 100.clean-disks Mon Mar 4 13:18:35 2002 @@ -33,6 +33,12 @@ sed -e 's/^[ ]*//' \ -e 's/[ ]*$//' \ -e 's/[ ][ ]*/ -o -name /g'` + [ -n "$daily_clean_disks_excludes" ] && + excl="$excl ! -path "`echo "$daily_clean_disks_excludes" | + sed -e 's/^[ ]*//' \ + -e 's/[ ]*$//' \ + -e 's/[ ][ ]*/ -a ! -path /g'` && + excl="( $excl ) -a" case "$daily_clean_disks_verbose" in [Yy][Ee][Ss]) @@ -41,9 +47,21 @@ print=;; esac + # $print is currently meaningless, but retained for if + # and when 'find' without "-print" actually inhibits output. + # $out is a hack until then. + + out=/var/run/_100_clean-disks_out.$$ rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \ - \( $args \) -atime +$daily_clean_disks_days -delete $print | - tee /dev/stderr | wc -l) + $excl \( $args \) -atime +$daily_clean_disks_days \ + -delete $print | tee $out | wc -l) + if [ -n "$print" ] + then + cat $out + else + echo " (output inhibited)" + fi + rm -f $out [ -z "$print" ] && rc=0 [ $rc -gt 1 ] && rc=1 set -f glob --- 110.clean-tmps.orig Mon Jan 28 07:13:17 2002 +++ 110.clean-tmps Mon Mar 4 12:00:53 2002 @@ -36,15 +36,40 @@ *) print=;; esac + case "$daily_clean_tmps_prune" in + [Yy][Ee][Ss]) + delete=-delete;; + *) + delete=;; + esac + # $print is currently meaningless, but retained for if + # and when 'find' without "-print" actually inhibits output. + # $out is a hack until then. + + out=/var/run/_110_clean_tmps_out.$$ + tmp=/var/run/_110_clean_tmps_tmp.$$ rc=$(for dir in $daily_clean_tmps_dirs do [ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && { find -d . -type f $args -delete $print find -d . ! -name . -type d -empty -mtime \ - +$daily_clean_tmps_days -delete $print + +$daily_clean_tmps_days $delete $print > $tmp + if [ -s $tmp ]; then + echo -n " Empty directories" + [ -n "$delete" ] && echo -n " removed" + echo ":" + sed "s,^\\., $dir," $tmp + fi } | sed "s,^\\., $dir," - done | tee /dev/stderr | wc -l) + done | tee $out | wc -l) + if [ -n "$print" ] + then + cat $out + else + echo " (output inhibited)" + fi + rm -f $out $tmp [ -z "$print" ] && rc=0 [ $rc -gt 1 ] && rc=1 set -f glob >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message