#!MARKER_SHELL_CMD PATH=/bin:/usr/bin PROGNAME=`basename $0` ############################################################################### # # # MAIL TRANSFER PROGRAM - USES SENDMAIL (SEND) AND FETCHMAIL (GET) # # # ############################################################################### ############################################################################### # # Things you should know about this script: # # It is stored under RCS! Keep it that way! If you want a history of # changes made to this script then refer to rlog(1) - don't look here! # ############################################################################### ############################################################################### # # CONFIGURABLE STUFF STARTS HERE # ############################################################################### ############################################################################### # # CONFIGURABLE STUFF ENDS HERE # ############################################################################### FACILITY=mail VERSION="MARKER_PATCHLEVEL" # $Header: /home/ahuxley/dev/arc/ppplc/lib/mail/RCS/mail-sendmail+fetchmail.shpp,v 1.5 1999/04/28 11:08:50 alexis Exp $ ############################################################################### # # MAIN FUNCTION (called from very bottom of script) # ############################################################################### main() { ########################################################################### # # PROCESS OPTIONS # ########################################################################### while [ "X$1" != X ]; do case "$1" in -V) echo "$PROGNAME version $VERSION" exit 0 ;; -d) [ "X$2" = X ] && usage VERBOSE_LEVEL=$2 shift ;; -v) VERBOSE_LEVEL=3 ;; -*) usage ;; *) break ;; esac shift done # list of users or the word 'all' must be supplied. [ "X$1" != X ] && usage # Are locks required? Yes. Sendmail does it's own locking, but for # fetchmail it might be advisable. But we lock it now just to # ensure we don't get half way through and then generate an error. lock DUMMY gen_lock_file_name || error "lock failed" ########################################################################### # # SEND MAIL # ########################################################################### exec MARKER_SENDMAIL_CMD -q ########################################################################### # # GET MAIL # ########################################################################### # Nothing to do! for ID in $*; do [ $ID = all ] && { error -f "'all' is not supported yet"; break; } info "retrieving mail for $ID" if [ $VERBOSE_LEVEL -ge 3 ]; then su - $ID -c "MARKER_FETCHMAIL_CMD -v" else su - $ID -c MARKER_FETCHMAIL_CMD fi done unlock DUMMY gen_lock_file_name debug 5 "all done" } gen_lock_file_name() { typeset LOCK_WHAT LOCK_WHAT=$1 echo MARKER_LOCK_DIR/$PROGNAME.pid } usage() { { echo "Usage: $PROGNAME [ -d | -v ] { ... | all }" echo " $PROGNAME -V" } >&2 exit 1 } #shpp include utils.sh.shpp #shpp include gep.sh.shpp