home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20110718.etc.tar.gz / bradford.20110718.etc.tar / etc / ppp / poll.tcpip < prev   
Text File  |  2006-06-02  |  3KB  |  120 lines

  1. #!/bin/bash
  2. #
  3. # /etc/ppp/poll.tcpip
  4. #
  5. # Script for polling mail and news, setting system
  6. # time, and sending mails over temporary TCP/IP connections.
  7. #
  8. # Author: Werner Fink <werner@suse.de>
  9. #
  10.  
  11. #
  12. # Check our lock file
  13. #
  14. if test -e /var/run/poll.lock ; then
  15.     running=false
  16.     read lpid < /var/run/poll.lock
  17.     for l in /proc/$lpid/fd/* ; do
  18.     test -L $l || continue
  19.     test $0 -ef $l && running=true
  20.     done
  21.     test "$running" = "true" && exit 0
  22.     unset l lpid running
  23. fi
  24. trap 'echo' SIGHUP SIGINT SIGQUIT
  25. trap 'rm -f /var/run/poll.lock; exit 1' SIGTRAP SIGBUS SIGKILL SIGPIPE SIGTERM
  26. trap 'rm -f /var/run/poll.lock; exit 0' EXIT
  27. echo $$ > /var/run/poll.lock
  28.  
  29. # Tell system what we're doing
  30. logger -t poll.tcpip -p mail.notice " Starting mail and news send/fetch"
  31.  
  32. #
  33. # Check resources and settings
  34. #
  35.  
  36. #
  37. # Time to get a stable connenction
  38. #
  39. sleep 5
  40.  
  41. #
  42. # Now set system time if we have some NTP servers
  43. # and no running ntp.
  44. #
  45. /usr/sbin/rcntp status &> /dev/null
  46. if test $? -eq 3 ; then
  47.     /usr/sbin/rcntp ntptimeset
  48. else
  49.     /usr/sbin/rcntp try-restart-iburst &> /dev/null \
  50.        || /usr/sbin/rcntp ntptimeset
  51. fi
  52.  
  53. #
  54. # Do we get mails via UUCP over TCP/IP?
  55. # Note that we only support taylor configuration.
  56. # We seek for the available systems which are
  57. # connected with TCP/IP to do a UUCP file transfer.
  58. #
  59. while true ; do
  60.     test -x   /usr/lib/uucp/uucico         || break
  61.     test -r   /etc/uucp/call               || break
  62.     test -r   /etc/uucp/sys                || break
  63.     systems=""
  64.     while read sys login passwd rest ; do
  65.     case "$sys" in
  66.         \#*|"") continue ;;
  67.         *)      systems="$systems $sys"
  68.     esac
  69.     done < /etc/uucp/call
  70.     for sys in $systems ; do
  71.     type=$(sed -n "
  72.         /^system[[:space:]]\+$sys/,/^\(system\|\$\)/ {
  73.         s/^port\W\+\(\w\+\)\$/\1/p
  74.         }" < /etc/uucp/sys)
  75.     test "$type" = tcp || continue
  76.     /usr/lib/uucp/uucico -c -D -S $sys
  77.     done
  78.     break
  79. done
  80.  
  81. #
  82. # Do we get mails with fetchmail over pop3/imap?
  83. # We support only a system wide configuration
  84. # file /etc/fetchmailrc.
  85. #
  86. while true ; do
  87.     test -x   /usr/bin/fetchmail           || break
  88.     test -r   /etc/fetchmailrc             || break
  89.     /usr/bin/fetchmail -f /etc/fetchmailrc
  90.     break
  91. done
  92.  
  93. #
  94. # Do we get news with fetchnews?
  95. #
  96. while true ; do
  97.     test -x   /usr/sbin/fetchnews           || break
  98.     test -s   /etc/leafnode/config          || break
  99.     test -e   /var/lock/news/fetchnews.lck  && break
  100.     /usr/sbin/fetchnews
  101.     break
  102. done
  103.  
  104. #
  105. # Let's throw our mails out here. This is done as the last
  106. # point to avoid mail loops.
  107. #
  108. if test -s /etc/sendmail.cf -a -s /etc/mail/submit.cf ; then
  109.     /usr/sbin/sendmail -L sendmail-client -Ac -q
  110.     sleep 3
  111.     /usr/sbin/sendmail -L sendmail -Am -q
  112. else
  113.     /usr/sbin/sendmail -q
  114. fi
  115.  
  116. # Tell system what we're done
  117. logger -t poll.tcpip -p mail.notice " Done mail and news send/fetch"
  118. #
  119. exit 0
  120.