home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / smail-3.1.28 / samples / arcnet / recvd.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1990-10-23  |  1.6 KB  |  49 lines

  1. : /bin/sh
  2. # @(#)samples/arcnet/recvd.sh    1.2 10/24/90 05:19:45
  3. #
  4. # recvd - Deliver mail which has been received on this node over arcnet
  5. #
  6. # SYNOPSIS
  7. #    recvd [ sleep-interval ]
  8. #
  9. # DESCRIPTION
  10. #    The recvd shell script should be started from the /etc/rc
  11. #    file for all machines on an arcnet that wish to receive
  12. #    mail.  These machines must have secure networking disabled
  13. #    as daemons cannot interactively enter passwords.
  14. #
  15. #    The shell script wakes up at intervals and looks for files
  16. #    under the directory /usr/spool/smail/forpro of the form
  17. #    hostname/done/msgid, where hostname is the name of a host
  18. #    that sent a message, and msgid is a 14 character message
  19. #    identifier which begins with a digit.  Each such file
  20. #    should have a corresponding message file in hostname/msgid,
  21. #    which contains SMTP commands to use for delivery.  Each
  22. #    message file is delivered by calling smail, and then the
  23. #    message file and the "done" file are removed.
  24. #
  25. #    The default interval between times that the script checks
  26. #    for new messages is 5 minutes.  This can be changed by giving
  27. #    a time in seconds as the first argument for the command.
  28.  
  29. FORPRO_SPOOL_DIR=/usr/spool/smail/forpro
  30. SLEEP_TIME="${1-300}"
  31. SMAIL=/usr/lib/sendmail
  32.  
  33. # change to the directory containing new mail
  34. cd $FORPRO_SPOOL_DIR
  35.  
  36. while :; do
  37.     find */done -type f -name '[0-9]*' -print | while read done_file; do
  38.     message_file="`echo $done_file | sed 's,/done/,/,'`"
  39.     if [ -f "$message_file" ]; then
  40.         cat "$message_file" | $SMAIL -bS
  41.         rm -f "$message_file"
  42.     fi
  43.     rm -f "$done_file"
  44.     done
  45.     sleep "$SLEEP_TIME"
  46. done
  47.  
  48. exit 0
  49.