diff options
author | Rob Funk <rfunk@funknet.net> | 2004-06-08 03:59:01 +0000 |
---|---|---|
committer | Rob Funk <rfunk@funknet.net> | 2004-06-08 03:59:01 +0000 |
commit | d78b61e3efaea197a6e5b2b72bf2981a9ed69461 (patch) | |
tree | 1704e13ce5d767d59868a2d5e834cb2e988ed90f /contrib/maildaemon | |
parent | d9e84e176fe538e110d9612f9832d69846e8d3e7 (diff) | |
download | fetchmail-d78b61e3efaea197a6e5b2b72bf2981a9ed69461.tar.gz fetchmail-d78b61e3efaea197a6e5b2b72bf2981a9ed69461.tar.bz2 fetchmail-d78b61e3efaea197a6e5b2b72bf2981a9ed69461.zip |
Add files from ESR's dev directory that weren't under version control
svn path=/trunk/; revision=3881
Diffstat (limited to 'contrib/maildaemon')
-rwxr-xr-x | contrib/maildaemon | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/contrib/maildaemon b/contrib/maildaemon new file mode 100755 index 00000000..3728c333 --- /dev/null +++ b/contrib/maildaemon @@ -0,0 +1,75 @@ +#!/bin/sh +# +# maildaemon, fetchmail driver intended to be invoked hourly by cron. +# +# Script by Larry Fahnoe <fahnoe@kegworks.mn.org>, who writes: +# +# This is intended to support a standalone system (NeXTSTEP in this case) +# which makes manual, on-demand PPP connections to the outside world. The +# script is run as the target user from cron on an hourly basis. If it +# finds a PPP link is up (it sees routes on a PPP interface), fetchmail is +# invoked. If the link is not up, and the hour is in the list of hours that +# connections should be made, the link is brought up and fetchmail is +# invoked. The program or script used to bring up the link should return an +# exit status which reflects whether the link actually came up. +# +# I wrote this because I wanted to be able to have control over the amount +# of time spent connected to an ISP and yet still be able to poll for mail +# at intervals that made sense to me. One limitation of this script is that +# it does not take into account that an existing PPP link might be going to +# a different ISP or network. +# + +# You'll have to configure these +USER=fahnoe # your name +HOME=/Users/fahnoe # home directory (for the logfile) +FORCEHOURS="05 09 13 17" # when to bring the link up if it's not already +SERVER=mailserver.isp.com # mailserver host name + +# Link initialization and wrapup scripts (you may have to configure these) +PPPUP="/usr/local/bin/pppup $SERVER" +PPPDOWN=/usr/local/bin/pppdown + +PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin:/usr/etc +export PATH USER HOME + +LOG=$HOME/log/maildaemon.log + +# get the mail, depends on $HOME/.fetchmailrc and $USER +FETCHMAIL( ) { + ( echo "`date` $SERVER" + fetchmail $SERVER + if [ $? -gt 1 ] + then + echo "`date` $SERVER (evil things happened in fetchmail)" + fi + ) >> $LOG 2>&1 +} + +# if the link is already up, check for mail. +# if the hour is in FORCEHOURS, force the link up and check for mail. +(netstat -rn | awk '{ print $6 }' | grep ppp[0-9] > /dev/null) +if [ $? -eq 0 ] +then + FETCHMAIL +else + hour=`date | sed -e 's/:/ /g' | awk '{ print $4 }'` + for x in $FORCEHOURS + do + if [ $hour = $x ] + then + $PPPUP + if [ $? -eq 0 ] + then + FETCHMAIL + $PPPDOWN + else + echo "`date` $SERVER (link establishment failure)" >> $LOG + exit 1 + fi + fi + done +fi + +exit + |