home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / mail / transpor / ifmail23.z / ifmail23 / ifmail / misc / contrib / ifpoll < prev    next >
Encoding:
Text File  |  1994-02-13  |  2.1 KB  |  99 lines

  1. #!/bin/sh
  2. # ver 0.7
  3. # ifpoll, poll my boss node or the node given as argument 1
  4. #
  5. # i start this shell script every day by crond, but you can
  6. # start it also by hand :) start it as the owner of ifcico.
  7. # rasca, berlin 1993 (Rasca Gmelch, 2:2410/305.4)
  8. #
  9.  
  10. # where "ifcico" and "ifpack" reside
  11. FIDOPATH=/usr/local/lib/fnet
  12.  
  13. # logfile of ifcico
  14. IFLOG=$FIDOPATH/log/log
  15.  
  16. # owner of "ifcico"
  17. IFCICO_OWNER=uucp
  18.  
  19. # sysop of fido stuff
  20. IFCICO_SYSOP=rasca@luzifer
  21.  
  22. # my boss node (default address to poll)
  23. NODE="f305.n2410.z2.fidonet.org"
  24.  
  25. # how often should i try to call NODE?
  26. MaxTry=5
  27.  
  28. # delay between outgoing calls in seconds
  29. DELAY=240
  30.  
  31. # where to log processing - file or tty/console
  32. INFO_TTY=/dev/tty1
  33.  
  34.  
  35.  
  36. echo "`date \"+%b %d %T\"` ifpoll[$$]: starting" >> $INFO_TTY
  37.  
  38. # remember me, not to run as root..
  39. #
  40. if [ `whoami` != "$IFCICO_OWNER" ]; then
  41.     echo "*** run $0 as the owner of ifcico ***"
  42.     echo "`date \"+%b %d %T\"` ifpoll[$$]: wrong uid (rc 2)" >> $INFO_TTY
  43.     exit 2
  44. fi
  45.  
  46. # argv[1] is the optional node to call
  47. #
  48. if [ "$1" != "" ]; then
  49.     if [ "$1" = "-?" ] || [ "$1" = "-h" ]; then
  50.         echo "usage: ifpoll [<node>]"
  51.         exit 3
  52.     else
  53.         NODE=$1
  54.     fi
  55. fi
  56.  
  57. # let's pack the fido stuff..
  58. #
  59. $FIDOPATH/ifpack
  60.  
  61. # loop until ifcico could connect the node or MaxTry is encountered
  62. #
  63. i=1; errlv=1
  64. while let 'i <= MaxTry' && let 'errlv != 0'
  65. do
  66.     echo -n "`date \"+%b %d %T\"` ifpoll[$$]: $i. try ($NODE) " >> $INFO_TTY
  67.     #
  68.     # start ifcico in master mode ..
  69.     #
  70.     $FIDOPATH/ifcico -r 1 $NODE
  71.     errlv=$?
  72.     if [ $errlv != "0" ]; then
  73.         echo "failed" >> $INFO_TTY
  74.         if [ $i != $MaxTry ]; then
  75.             sleep $DELAY
  76.         fi
  77.         let i=i+1
  78.     else
  79.         echo "ok :)" >> $INFO_TTY
  80.     fi
  81. done
  82.  
  83. # if the poll was fine, unpacking..
  84. #
  85. if [ $errlv = "0" ]; then
  86.     echo "`date \"+%b %d %T\"` ifpoll[$$]: unpacking.. " >> $INFO_TTY
  87.     $FIDOPATH/ifunpack
  88.     # add here some additional lines for processing tic files or
  89.     # incoming file-lists or simular..
  90. else
  91.     # write me a mail about the failed poll
  92.     tail --lines=20 $IFLOG | elm -s "ifpoll: failed" $IFCICO_SYSOP >/dev/null
  93. fi
  94.  
  95. echo "`date \"+%b %d %T\"` ifpoll[$$]: finished (rc $errlv)" >> $INFO_TTY
  96.  
  97. # return the errorlevel of ifcico
  98. exit $errlv
  99.