;****** axuucp/axumsd ********************************************************
;
;   NAME
;	axumsd - Mailer daemon for AXsh to UMS delivery
;
;   SYNOPSIS
;	axumsd
;
;   DESCRIPTION
;	axumsd oberserves the system mailbox of users who's mail is to be
;	delivered to a foreign system thru UMS.  As soon as there is a new
;	message it will be imported into the UMS for further purposes.
;
;   AUTHOR
;	Tobias Ferber <tf@ganymed.hall.sub.org>
;
;*****************************************************************************

;# axumsd -- daemon to deliver pending AXsh mail for local users to UMS

lab loop

  failat 21
  set mbox=`waitnotify fmt=%s uumail:root uumail:tf uumail:system`

  if warn
    skip buythefarm
  endif

  failat 10
  if exists $mbox ;notify was not `delete'
    set usr=`rx "say substr('$mbox',1+lastpos(':','$mbox'))"`
    rx >nil: ums:rexx/mbox2ums.rexx $user < $mbox
    ums:bin/setfolder $user gnubbel quiet
    delete quiet $mbox
  endif

skip back loop

lab buythefarm
  echo "axumsd terminated."
  quit
