1997-08-12 17:48:49 +00:00
|
|
|
#!/bin/sh -
|
|
|
|
#
|
1999-02-14 20:06:02 +00:00
|
|
|
# $Id: periodic.sh,v 1.7 1999/01/01 17:37:33 billf Exp $
|
1997-08-12 17:48:49 +00:00
|
|
|
#
|
|
|
|
# Run nightly periodic scripts
|
|
|
|
#
|
|
|
|
# usage: periodic { daily | weekly | monthly } - run standard periodic scripts
|
|
|
|
# periodic /absolute/path/to/directory - run periodic scripts in dir
|
|
|
|
#
|
|
|
|
|
1997-08-13 06:02:18 +00:00
|
|
|
usage () {
|
1997-08-12 17:48:49 +00:00
|
|
|
echo "usage: $0 <directory of files to execute>" 1>&2
|
1997-08-13 06:02:18 +00:00
|
|
|
echo "or $0 { daily | weekly | monthly }" 1>&2
|
1997-08-12 17:48:49 +00:00
|
|
|
exit 1
|
1997-08-13 06:02:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# -lt 1 ] ; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
1999-02-14 20:06:02 +00:00
|
|
|
# If possible, check the global system configuration file,
|
|
|
|
# to see if there are additional dirs to check
|
|
|
|
if [ -r /etc/defaults/rc.conf ]; then
|
|
|
|
. /etc/defaults/rc.conf
|
|
|
|
elif [ -r /etc/rc.conf ]; then
|
1997-08-13 06:02:18 +00:00
|
|
|
. /etc/rc.conf
|
1997-08-12 17:48:49 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
dir=$1
|
|
|
|
run=`basename $dir`
|
|
|
|
|
1997-08-13 06:02:18 +00:00
|
|
|
# If a full path was not specified, check the standard cron areas
|
1997-08-12 17:48:49 +00:00
|
|
|
|
|
|
|
if [ "$dir" = "$run" ] ; then
|
1997-08-13 06:02:18 +00:00
|
|
|
dirlist=""
|
1997-08-19 16:49:35 +00:00
|
|
|
for top in /etc/periodic ${local_periodic} ; do
|
1997-08-13 06:02:18 +00:00
|
|
|
if [ -d $top/$dir ] ; then
|
|
|
|
dirlist="${dirlist} $top/$dir"
|
|
|
|
fi
|
|
|
|
done
|
1997-08-12 17:48:49 +00:00
|
|
|
|
1997-08-13 06:02:18 +00:00
|
|
|
# User wants us to run stuff in a particular directory
|
|
|
|
else
|
|
|
|
for dir in $* ; do
|
|
|
|
if [ ! -d $dir ] ; then
|
|
|
|
echo "$0: $dir not found" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
1997-08-12 17:48:49 +00:00
|
|
|
|
1997-08-13 06:02:18 +00:00
|
|
|
dirlist="$*"
|
1997-08-12 17:48:49 +00:00
|
|
|
fi
|
|
|
|
|
1999-01-01 17:37:33 +00:00
|
|
|
host=`hostname`
|
1997-08-12 17:48:49 +00:00
|
|
|
echo "Subject: $host $run run output"
|
|
|
|
|
1997-08-13 06:02:18 +00:00
|
|
|
# Execute each executable file in the directory list. If the x bit is not
|
1997-08-12 17:48:49 +00:00
|
|
|
# set, assume the user didn't really want us to muck with it (it's a
|
|
|
|
# README file or has been disabled).
|
|
|
|
|
1997-08-13 06:23:54 +00:00
|
|
|
for dir in $dirlist ; do
|
|
|
|
for file in $dir/* ; do
|
1998-12-29 22:48:54 +00:00
|
|
|
if [ -x $file -a ! -d $file ] ; then
|
1997-08-13 06:02:18 +00:00
|
|
|
$file
|
|
|
|
fi
|
|
|
|
done
|
1997-08-13 06:23:54 +00:00
|
|
|
done
|