5 # Run nightly periodic scripts
7 # usage: periodic { daily | weekly | monthly } - run standard periodic scripts
8 # periodic /absolute/path/to/directory - run periodic scripts in dir
12 echo "usage: $0 <directory of files to execute>" 1>&2
13 echo "or $0 { daily | weekly | monthly }" 1>&2
17 if [ $# -lt 1 ] ; then
21 # If possible, check the global system configuration file,
22 # to see if there are additional dirs to check
23 if [ -r /etc/defaults/periodic.conf ]; then
24 . /etc/defaults/periodic.conf
30 tmp_output=`mktemp ${TMPDIR:-/tmp}/periodic.XXXXXXXXXX`
32 # Execute each executable file in the directory list. If the x bit is not
33 # set, assume the user didn't really want us to muck with it (it's a
34 # README file or has been disabled).
38 # Where's our output going ?
39 eval output=\$${arg##*/}_output
41 /*) pipe="cat >>$output";;
43 *) pipe="mail -E -s '$host ${arg##*/} run output' $output";;
46 success=YES info=YES badconfig=NO empty_output=YES # Defaults when ${run}_* aren't YES/NO
47 for var in success info badconfig empty_output
49 case $(eval echo "\$${arg##*/}_show_$var") in
50 [Yy][Ee][Ss]) eval $var=YES;;
51 [Nn][Oo]) eval $var=NO;;
60 echo "$0: $arg not found" >&2
64 for top in /etc/periodic ${local_periodic}
66 [ -d $top/$arg ] && dirlist="$dirlist $top/$arg"
77 if [ -x $file -a ! -d $file ]
80 processed=$(($processed + 1))
81 $file </dev/null >$tmp_output 2>&1
86 0) [ $success = NO ] && output=FALSE;;
87 1) [ $info = NO ] && output=FALSE;;
88 2) [ $badconfig = NO ] && output=FALSE;;
90 [ $output = TRUE ] && { cat $tmp_output; empty=FALSE; }
92 cp /dev/null $tmp_output
98 if [ $empty_output = TRUE ]
100 [ $processed = 1 ] && plural= || plural=s
101 echo "No output from the $processed file$plural processed"
105 echo "-- End of $arg output --"