home *** CD-ROM | disk | FTP | other *** search
- #
- # SCCS ID: @(#)sunfax.daily 1.2 94/07/13
- #
- # clean up the spool directory
- #
- # Delete
- # - log files that have been around for 90 days
- # - warn about requests 2 days old (REQWARN + 1)
- # - delete requests 5 days old (REQDELETE + 1)
- # - delete destination status files 7 days old (STATDELETE + 1)
-
- DELETELOG=89 # Since we use a > test
- REQWARN=1 # "
- REQDELETE=4 # "
- STATDELETE=6 # "
-
- #
- # Locate the SunFax spool directory
- #
-
- if [ ! -r /etc/sunfax.conf ]
- then
- echo "Cannot locate /etc/sunfax.conf file"
- exit 1
- fi
-
- line=`grep spool-directory /etc/sunfax.conf`
-
- if [ -z "$line" ]
- then
- fatal "/etc/sunfax.conf is missing the spool-directory parameter"
- fi
-
- SPOOLDIR=`expr "$line" : '.*spool-directory *= *\(.*\)'`
-
- #
- # At the first of every month, save the old log and accounting files
- #
-
- if [ `date +%d` -eq 01 ]
- then
- case `date +%m` in
- 01) NAME=Dec ;;
- 02) NAME=Jan ;;
- 03) NAME=Feb ;;
- 04) NAME=Mar ;;
- 05) NAME=Apr ;;
- 06) NAME=May ;;
- 07) NAME=Jun ;;
- 08) NAME=Jul ;;
- 09) NAME=Aug ;;
- 10) NAME=Sep ;;
- 11) NAME=Oct ;;
- 12) NAME=Nov ;;
- *) NAME=Xxx ;;
- esac
-
- if [ -s $SPOOLDIR/log ]
- then
- cp $SPOOLDIR/log $SPOOLDIR/log.$NAME
- > $SPOOLDIR/log
- fi
-
- if [ -s $SPOOLDIR/acct ]
- then
- cp $SPOOLDIR/acct $SPOOLDIR/acct.$NAME
- > $SPOOLDIR/acct
- fi
-
- #
- # Get rid of old log files...
- #
-
- cd $SPOOLDIR
- find . -name 'log.???' -mtime +$DELETELOG -print | xargs -l /bin/rm -f
- find . -name 'acct.???' -mtime +$DELETELOG -print | xargs -l /bin/rm -f
- fi
-
- #
- # Get rid of old destination status files
- #
-
- cd $SPOOLDIR/deststatus
- find . -type f -mtime +$STATDELETE -print | xargs -l /bin/rm -f
-
- #
- # Find and report all requests that have been suspended for two days or
- # more.
- #
-
- cd $SPOOLDIR/destinations
- find . -type f -name 'cf*' -ctime +$REQWARN -print > /tmp/fax.$$
-
- if [ -s /tmp/fax.$$ ]
- then
- echo "Subject: Destination Directory Cleanup" > /tmp/faxc.$$
- echo " " >> /tmp/faxc.$$
- echo "WARNING!!! The following files related to fax requests" >> /tmp/faxc.$$
- echo "have not been scheduled for at least two days. They will" >> /tmp/faxc.$$
- echo "deleted shortly. (These requests may be rescheduled or" >> /tmp/faxc.$$
-
- echo "deleted using the 'Fax Status' option of from the" >> /tmp/faxc.$$
- echo "SunFax composer." >> /tmp/faxc.$$
- echo " " >> /tmp/faxc.$$
- cat /tmp/fax.$$ >> /tmp/faxc.$$
- mail root < /tmp/faxc.$$
- rm -f /tmp/fax.$$
- rm -f /tmp/faxc.$$
- fi
-
- #
- # Find will generate strings of the form ./12345/cfxxxx for each old
- # (suspended) request file. This sed script converts each such line into
- # a line of the form 'rm ./12345/*xxxx*' which is then fed into the shell
- # to remove all related sf and df files.
- #
-
- find . -type f -name 'cf*' -perm 610 -ctime +$REQDELETE -print | sed 's/\(.*\)cf\(.*\)/rm -f \1*\2*/' | sh
-
- rm -f /tmp/fax.$$
-