home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume6 / uupoll / Uupoll
Text File  |  1989-03-06  |  3KB  |  130 lines

  1. : #     Uupoll (1.0)
  2. : #
  3. : #    Bourne shell script to force polling of a remote system
  4. : #
  5. : #  Written by: 
  6. : #     Michael M. Levin - Feb, 1988
  7. : #
  8. : #                Copyright (c) 1988 
  9. : #                 Michael M. Levin
  10. : #    
  11. : #            (levin@srhqla.UUCP, levin@magnus.UUCP)
  12. : #    
  13. : #    
  14. : #    This script is intended for Public distribution. It shall
  15. : #    not be distributed in any manner whatsoever, nor packaged for 
  16. : #    enhancement to a commercial product in any form, for profit. 
  17. : #    This agreement also stipulates that the users of this script 
  18. : #    will not remove the names of the origional Author nor this
  19. : #    copyright notice from this script. 
  20. : #
  21. : #  Revision: Version 1.0 Feb 1988 
  22. : #
  23. : #    Developed for System V using HoneyDanBer uucp. 
  24. : #    (AT&T Basic Networking Utilities)
  25. : #
  26. : #     Last Updated:     Sat Feb 27 17:35:00 PST 1988
  27. : #
  28. : #  Usage:
  29. : #
  30. : #     This shell must be run by either super-user or uucp.
  31. : #    It causes a poll request to be entered (or touched, if
  32. : #    one already exists) for the specified system.  Even if
  33. : #    the file permissions are changed to allow execution by
  34. : #    other users, the shell will abort itself.
  35. : #    If the shell is started with only a system name, it simply
  36. : #    creates an entry which will be handled the next time that
  37. : #    uusched is run.  To also cause uusched to start up, start
  38. : #    it with a '-n' (NOW) option ahead of the system name.
  39. : #    For example:
  40. : #
  41. : #        Create entry only:    Uupoll sysname
  42. : #        Start uusched also:    Uupoll -n sysname
  43.  
  44. PATH=/bin:/usr/bin:/etc:/usr/lib/uucp
  45. export PATH
  46. SYS=/usr/lib/uucp/Systems    # Full pathname to Systems file(s)
  47. SPOOL=/usr/spool/uucp        # Mail system spool directory
  48. UUCP=uucp            # Local uid name for uucp (usually uucp)
  49. MAIL=mail            # Local gid name for mail (usually mail)
  50. ROOT=root            # Local uid name for root (usually root)
  51. NOW=NO
  52. USAGE="\tusage: ${0} [-n] sysname"
  53. umask 022
  54. set +e
  55.  
  56. : #    Determine that we are either uucp or root:
  57.  
  58.     if id|cut -f2 -d\(|cut -f1 -d\)|grep "^${UUCP}$" > /dev/null
  59.     then
  60.         continue
  61.     elif id|cut -f2 -d\(|cut -f1 -d\)|grep "^${ROOT}$" > /dev/null
  62.     then
  63.         continue
  64.     else
  65.         echo "${0}: you must be uucp to run this.  FAILED"
  66.         exit 2
  67.     fi
  68.  
  69.  
  70. : #    Verify that a system name has been passed to us:
  71.  
  72.     set -- `getopt n $*`
  73.     if [ $? != 0 ]
  74.     then
  75.         echo $USAGE
  76.         exit 2
  77.     fi
  78.     for i in $*
  79.     do
  80.         case $i in
  81.         -n)        NOW=YES; shift;; # Is 'NOW' flag set??
  82.         --)        shift; break;;
  83.         esac
  84.     done
  85.     if [ $# != 1 ]
  86.     then
  87.         echo "${0}: you must specify system name.  FAILED"
  88.         exit 2
  89.     fi
  90.  
  91.  
  92. : #    Make sure system name exists in our local Systems file:
  93.  
  94.     if uuname | grep "^${1}$" > /dev/null
  95.     then
  96.         site=$1
  97.         continue
  98.     else
  99.         echo "${0}: '"$1"' is not a valid system name.  FAILED"
  100.         exit 2
  101.     fi
  102.  
  103.  
  104. : #    If a spool directory doesn't exist for this system, create one.
  105.  
  106.     if [ ! -d $SPOOL/$site ]
  107.     then
  108.         mkdir $SPOOL/$site
  109.         chown $UUCP $SPOOL/$site
  110.         chgrp $MAIL $SPOOL/$site
  111.     fi
  112.  
  113.  
  114. : #    Create the poll entry in the specified system's spool directory.
  115.  
  116.     j=`expr $site : '\(.\{1,7\}\)'`
  117.     touch $SPOOL/$site/C.${j}n0000
  118.     chown $UUCP $SPOOL/$site/C.${j}n0000
  119.     chgrp $MAIL $SPOOL/$site/C.${j}n0000
  120.  
  121. : #    If NOW option selected, start the scheduler.
  122.  
  123.     if [ $NOW = YES ]
  124.     then
  125.         touch $SPOOL/.Status/$site
  126.         rm $SPOOL/.Status/$site
  127.         nohup uusched > /dev/null &
  128.         nohup uuxqt > /dev/null &
  129.     fi
  130.