home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / Faximum / FAXserver / lib / sunfax.daily < prev   
Encoding:
Text File  |  1994-11-16  |  2.8 KB  |  121 lines

  1. #
  2. # SCCS ID: @(#)sunfax.daily    1.2    94/07/13
  3. #
  4. # clean up the spool directory
  5. #
  6. #  Delete
  7. #   - log files that have been around for 90 days
  8. #   - warn about requests 2 days old (REQWARN + 1)
  9. #   - delete requests 5 days old (REQDELETE + 1)
  10. #   - delete destination status files 7 days old (STATDELETE + 1)   
  11.  
  12. DELETELOG=89     #  Since we use a > test 
  13. REQWARN=1    #        "
  14. REQDELETE=4    #        "
  15. STATDELETE=6    #        "
  16.  
  17. #
  18. # Locate the SunFax spool directory
  19. #
  20.  
  21. if [ ! -r /etc/sunfax.conf ]
  22. then
  23.     echo "Cannot locate /etc/sunfax.conf file"
  24.     exit 1
  25. fi
  26.  
  27. line=`grep spool-directory /etc/sunfax.conf`
  28.  
  29. if [ -z "$line" ]
  30. then
  31.         fatal "/etc/sunfax.conf is missing the spool-directory parameter"
  32. fi
  33.  
  34. SPOOLDIR=`expr "$line" : '.*spool-directory *= *\(.*\)'`
  35.  
  36. #
  37. #  At the first of every month, save the old log and accounting files
  38. #
  39.  
  40. if [ `date +%d` -eq 01 ]
  41. then
  42.     case `date +%m` in
  43.        01) NAME=Dec ;;
  44.        02) NAME=Jan ;;
  45.        03) NAME=Feb ;;
  46.        04) NAME=Mar ;;
  47.        05) NAME=Apr ;;
  48.        06) NAME=May ;;
  49.        07) NAME=Jun ;;
  50.        08) NAME=Jul ;;
  51.        09) NAME=Aug ;;
  52.        10) NAME=Sep ;;
  53.        11) NAME=Oct ;;
  54.        12) NAME=Nov ;;
  55.         *) NAME=Xxx ;;
  56.     esac
  57.  
  58.     if [ -s $SPOOLDIR/log ]
  59.     then
  60.         cp $SPOOLDIR/log $SPOOLDIR/log.$NAME
  61.         > $SPOOLDIR/log
  62.     fi
  63.  
  64.     if [ -s $SPOOLDIR/acct ]
  65.     then
  66.         cp $SPOOLDIR/acct $SPOOLDIR/acct.$NAME
  67.         > $SPOOLDIR/acct
  68.     fi
  69.  
  70.     #
  71.     #  Get rid of old log files...
  72.     #
  73.  
  74.     cd $SPOOLDIR
  75.     find . -name 'log.???' -mtime +$DELETELOG -print | xargs -l /bin/rm -f
  76.     find . -name 'acct.???' -mtime +$DELETELOG -print | xargs -l /bin/rm -f
  77. fi
  78.  
  79. #
  80. #  Get rid of old destination status files
  81. #
  82.  
  83. cd $SPOOLDIR/deststatus
  84. find . -type f -mtime +$STATDELETE -print | xargs -l /bin/rm -f
  85.  
  86. #
  87. # Find and report all requests that have been suspended for two days or
  88. # more. 
  89. #
  90.  
  91. cd $SPOOLDIR/destinations
  92. find . -type f -name 'cf*' -ctime +$REQWARN -print > /tmp/fax.$$
  93.  
  94. if [ -s /tmp/fax.$$ ]
  95. then
  96.     echo "Subject: Destination Directory Cleanup" > /tmp/faxc.$$
  97.     echo " " >> /tmp/faxc.$$
  98.     echo "WARNING!!! The following files related to fax requests" >> /tmp/faxc.$$
  99.     echo "have not been scheduled for at least two days. They will" >> /tmp/faxc.$$
  100.     echo "deleted shortly.  (These requests may be rescheduled or" >> /tmp/faxc.$$
  101.  
  102.     echo "deleted using the 'Fax Status' option of from the" >> /tmp/faxc.$$
  103.     echo "SunFax composer." >> /tmp/faxc.$$
  104.     echo " " >> /tmp/faxc.$$
  105.     cat /tmp/fax.$$ >> /tmp/faxc.$$
  106.     mail root  < /tmp/faxc.$$
  107.     rm -f /tmp/fax.$$
  108.     rm -f /tmp/faxc.$$
  109. fi
  110.  
  111. #
  112. #  Find will generate strings of the form ./12345/cfxxxx for each old
  113. #  (suspended) request file.  This sed script converts each such line into
  114. #  a line of the form 'rm ./12345/*xxxx*' which is then fed into the shell
  115. #  to remove all related sf and df files.
  116. #
  117.  
  118. find . -type f -name 'cf*' -perm 610 -ctime +$REQDELETE -print | sed 's/\(.*\)cf\(.*\)/rm -f \1*\2*/' | sh
  119.  
  120. rm -f /tmp/fax.$$
  121.