2 # $Id: copi.ifpoll2,v 1.2 2012/06/29 22:33:42 tom Exp $
4 # Packets backup directory - You have to CREATE this directory
5 BAK=/var/spool/ifmail/BAK
8 IFLOG=/var/log/ifmail/sysiflog
11 IFLOGARC=/var/log/ifmail/TheLog
16 # how often should i try to call NODE?
19 # delay between outgoing calls in seconds
22 # where to log processing - file or tty/console
25 # Lets backup the log and use a new one
26 if [ -e $IFLOG ]; then
27 echo Rearranging logs...
28 cat $IFLOG >> $IFLOGARC
32 echo "`date \"+%b %d %T\"` ifpoll[$$]: starting" # >> $INFO_TTY
34 # remember me, not to run as root..
36 if [ `whoami` != "$IFCICO_OWNER" ]; then
37 echo "*** run $0 as the owner of ifcico ***"
38 echo "`date \"+%b %d %T\"` ifpoll[$$]: wrong uid (rc 2)" # >> $INFO_TTY
42 # argv[1] is the optional node to call
44 if [ "$1" != "" ]; then
45 if [ "$1" = "-?" ] || [ "$1" = "-h" ]; then
46 echo "usage: ifpoll [<node>]"
53 # let's pack the fido stuff..
57 # loop until ifcico could connect the node or MaxTry is encountered
60 while let 'i <= MaxTry' && let 'errlv != 0'
62 echo -n "`date \"+%b %d %T\"` ifpoll[$$]: $i. try ($NODE) " # >> $INFO_TTY
64 # start ifcico in master mode ..
66 $FIDOPATH/ifcico -r 1 $NODE
68 if [ $errlv != "0" ]; then
69 echo "failed" # >> $INFO_TTY
70 if [ $i != $MaxTry ]; then
75 echo "ok :)" # >> $INFO_TTY
79 # if the poll was fine, unpacking..
81 if [ $errlv = "0" ]; then
82 echo "`date \"+%b %d %T\"` ifpoll[$$]: unpacking.. " # >> $INFO_TTY
83 cp -f /var/spool/ifmail/inb/*.* $BAK
85 # add here some additional lines for processing tic files or
86 # incoming file-lists or simular..
88 # write me a mail about the failed poll
89 tail --lines=20 $IFLOG | elm -s "ifpoll: failed" $IFCICO_SYSOP >/dev/null
92 echo "`date \"+%b %d %T\"` ifpoll[$$]: finished (rc $errlv)" # >> $INFO_TTY
94 # Collect some infos...
96 echo "*** Outgoing File Transfer Stats: ***"
98 echo "*** Incoming File Transfer Stats: ***"
102 echo "---->> New mail: <<-----"
104 echo "---->> Personal mail: <<-----"
105 grep "mail from" $IFLOG
108 # return the errorlevel of ifcico