periodic.sh revision 42152
128112Spst#!/bin/sh - 228112Spst# 342152Shoek# $Id: periodic.sh,v 1.5 1997/08/19 16:49:35 pst Exp $ 428112Spst# 528112Spst# Run nightly periodic scripts 628112Spst# 728112Spst# usage: periodic { daily | weekly | monthly } - run standard periodic scripts 828112Spst# periodic /absolute/path/to/directory - run periodic scripts in dir 928112Spst# 1028112Spst 1128143Spstusage () { 1228112Spst echo "usage: $0 <directory of files to execute>" 1>&2 1328143Spst echo "or $0 { daily | weekly | monthly }" 1>&2 1428112Spst exit 1 1528143Spst} 1628143Spst 1728143Spstif [ $# -lt 1 ] ; then 1828143Spst usage 1928112Spstfi 2028112Spst 2128143Spst# If possible, check /etc/rc.conf to see if there are additional dirs to check 2228143Spstif [ -r /etc/rc.conf ] ; then 2328143Spst . /etc/rc.conf 2428143Spstfi 2528143Spst 2628112Spstdir=$1 2728112Spstrun=`basename $dir` 2828112Spst 2928143Spst# If a full path was not specified, check the standard cron areas 3028112Spst 3128112Spstif [ "$dir" = "$run" ] ; then 3228143Spst dirlist="" 3328424Spst for top in /etc/periodic ${local_periodic} ; do 3428143Spst if [ -d $top/$dir ] ; then 3528143Spst dirlist="${dirlist} $top/$dir" 3628143Spst fi 3728143Spst done 3828112Spst 3928143Spst# User wants us to run stuff in a particular directory 4028143Spstelse 4128143Spst for dir in $* ; do 4228143Spst if [ ! -d $dir ] ; then 4328143Spst echo "$0: $dir not found" 1>&2 4428143Spst exit 1 4528143Spst fi 4628143Spst done 4728112Spst 4828143Spst dirlist="$*" 4928112Spstfi 5028112Spst 5128112Spsthost=`hostname -s` 5228112Spstecho "Subject: $host $run run output" 5328112Spst 5428143Spst# Execute each executable file in the directory list. If the x bit is not 5528112Spst# set, assume the user didn't really want us to muck with it (it's a 5628112Spst# README file or has been disabled). 5728112Spst 5828145Spstfor dir in $dirlist ; do 5928145Spst for file in $dir/* ; do 6042152Shoek if [ -x $file -a ! -d $file ] ; then 6128143Spst $file 6228143Spst fi 6328143Spst done 6428145Spstdone 65