#!/bin/sh ## Author: Parv, parv UNDERSCORE AT yahoo DOT com ## Modified: Apr 25 2004 ## ## License: Free to use as you please w/ proper credit given ## ## Name: chkmail, plus symlinks ## ## Purpose: Combine fetchmail & mailstat(procmail) in one place; ## based on symlink names, visible output is different in each case. ## all output is logged to file(s); difference is only the stdout output. ## ## Usage: Too much to write for now; read the "case" block; ## will be updated properly ... sometime... ## umask=177 # to reset the statistics of procmail log MAILSTAT="${HOME}/extern/bin/mailstat-parv.perl -o -f ${HOME}/log/mail/procmail.log" #MAILSTAT=mailstat mkdir_fail() { mkdir -p "$1" rc=$? if [ ! $rc ] then echo "${1} directory could not be created, exiting..." 1>&2 exit $rc else return $rc fi } stat_ping() { $MAILSTAT date noise short || echo  } # set fetchmail general optins & log file # F_ARGS="-v --invisible" F_ARGS="-v -v --invisible" # F_LOG is directory; if mkdir_fail succeeds, then changed to file # F_LOG=${HOME}/log/mail # if mkdir fails, then exit # mkdir_fail "$F_LOG" && F_LOG=${F_LOG}/fetchmail.log touch "$F_LOG" case `basename $0` in # quitemail quitem*) fetchmail $F_ARGS --silent --logfile $F_LOG && $MAILSTAT > /dev/null 2>&1 ;; # semi quietmail semi-quietm*) fetchmail $F_ARGS --logfile $F_LOG && stat_ping ;; # readmail readm*) fetchmail $F_ARGS --logfile $F_LOG && $MAILSTAT > /dev/null 2>&1 && \ mutt -Z -y -F ${HOME}/cf/mutt/mutt.cf ;; # newmail or chkmail; chkmail being the actual name of this script newm*|chkm*) { fetchmail $F_ARGS | tee -a $F_LOG ; } && stat_ping ;; # safemail safem*) { fetchmail $F_ARGS --keep | tee -a $F_LOG ; } && stat_ping ;; # flushmail; delete old before getting new msgs flushm*) { fetchmail $F_ARGS --flush | tee -a $F_LOG ; } && stat_ping ;; # allmail; get both old(msgs marked seen) & new msgs allm*) { fetchmail $F_ARGS --all | tee -a $F_LOG ; } && stat_ping ;; # error (?) *) echo '* incorrect name given: ' $0 echo '* nothing is done; exiting...' exit 1 ;; esac #procmailnull