3 # maildaemon, fetchmail driver intended to be invoked hourly by cron.
5 # Script by Larry Fahnoe <fahnoe@kegworks.mn.org>, who writes:
7 # This is intended to support a standalone system (NeXTSTEP in this case)
8 # which makes manual, on-demand PPP connections to the outside world. The
9 # script is run as the target user from cron on an hourly basis. If it
10 # finds a PPP link is up (it sees routes on a PPP interface), fetchmail is
11 # invoked. If the link is not up, and the hour is in the list of hours that
12 # connections should be made, the link is brought up and fetchmail is
13 # invoked. The program or script used to bring up the link should return an
14 # exit status which reflects whether the link actually came up.
16 # I wrote this because I wanted to be able to have control over the amount
17 # of time spent connected to an ISP and yet still be able to poll for mail
18 # at intervals that made sense to me. One limitation of this script is that
19 # it does not take into account that an existing PPP link might be going to
20 # a different ISP or network.
23 # You'll have to configure these
24 USER=fahnoe # your name
25 HOME=/Users/fahnoe # home directory (for the logfile)
26 FORCEHOURS="05 09 13 17" # when to bring the link up if it's not already
27 SERVER=mailserver.isp.com # mailserver host name
29 # Link initialization and wrapup scripts (you may have to configure these)
30 PPPUP="/usr/local/bin/pppup $SERVER"
31 PPPDOWN=/usr/local/bin/pppdown
33 PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin:/usr/etc
36 LOG=$HOME/log/maildaemon.log
38 # get the mail, depends on $HOME/.fetchmailrc and $USER
40 ( echo "`date` $SERVER"
44 echo "`date` $SERVER (evil things happened in fetchmail)"
49 # if the link is already up, check for mail.
50 # if the hour is in FORCEHOURS, force the link up and check for mail.
51 (netstat -rn | awk '{ print $6 }' | grep ppp[0-9] > /dev/null)
56 hour=`date | sed -e 's/:/ /g' | awk '{ print $4 }'`
67 echo "`date` $SERVER (link establishment failure)" >> $LOG