1997-08-12 17:48:49 +00:00
|
|
|
#!/bin/sh -
|
|
|
|
#
|
1998-12-29 22:48:54 +00:00
|
|
|
# $Id: periodic.sh,v 1.5 1997/08/19 16:49:35 pst 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
|
|
|
|
|
|
|
|
# If possible, check /etc/rc.conf to see if there are additional dirs to check
|
|
|
|
if [ -r /etc/rc.conf ] ; then
|
|
|
|
. /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
|
|
|
|
|
|
|
|
host=`hostname -s`
|
|
|
|
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
|