Annotation of 43BSD/contrib/news/misc/batcher, revision 1.1

1.1     ! root        1: From [email protected] Mon Feb  3 14:24:25 1986
        !             2: Received: by seismo.CSS.GOV; Mon, 3 Feb 86 12:48:57 EST
        !             3: Return-Path: <sdcsvax!ncr-sd!greg>
        !             4: Received: by s3sun.CSS.GOV (4.24/s3-5.0)
        !             5:        id AA01660; Sun, 2 Feb 86 00:14:55 pst hops=0
        !             6: From: [email protected]
        !             7: Received: by sdcsvax.ucsd.edu (5.31/4.41)
        !             8:        id AA16013; Sat, 1 Feb 86 23:56:26 PST hops=0
        !             9: Date: Sat, 1 Feb 86 23:56:26 PST
        !            10: Message-Id: <[email protected]>
        !            11: To: [email protected], [email protected]
        !            12: Subject: Batcher script for news
        !            13: Status: R
        !            14: 
        !            15: :      shar:   Shell Archiver
        !            16: # Run this text with /bin/sh to create:
        !            17: #      batcher
        !            18: 
        !            19: # I sent this a few days ago, and haven't gotten a reply.  This one is a
        !            20: # revision that incorporates some fixes suggested by some other San Diego
        !            21: # sites that have been running it.  Again, lease let me know if it arrives,
        !            22: # otherwise I'll try retransmitting it in a few days.
        !            23: # 
        !            24: # This is a script that replaces sendbatch and csendbatch.  I recommend it to
        !            25: # you for inclusion in 2.10.3.  It has some nice attributes, particularly for
        !            26: # me, where I have a lot of news connections to maintain.  The most useful to
        !            27: # me is that the default if no arguments are given is to send to everybody,
        !            28: # so that I don't have to run around modifying crontab all the time -- all
        !            29: # of the maintenance is in news/sys.
        !            30: # 
        !            31: # Here are some sample sites from news/sys to show how it works:
        !            32: # 
        !            33: # sdcsvax:sd,sdnet,ca,to.sdcsvax::uux - -r -n sdcsvax!rnews
        !            34: # sdcsvax:net,fa,mod,na,usa:F:/usr/spool/batch/c.sdcsvax
        !            35: # ncrcae:net,fa,mod,na,usa,ncr,to.ncrcae:F:/usr/spool/batch/c.ncrcae
        !            36: # local:net,fa,mod,na,usa,ca,sdnet,sd,to.local:F:/usr/spool/batch/b.local
        !            37: # 
        !            38: # The name chosen determines the type of transmission; the "b." prefix
        !            39: # causes news to be sent batched and the "c." prefix causes news to be
        !            40: # sent compressed (and batched).
        !            41: # 
        !            42: # The batcher works by looking for files in /usr/spool/batch with a prefix
        !            43: # of "[abc]."; if it is invoked with no arguments, it will pick up all such
        !            44: # files, otherwise it only picks up files with those prefixes and the names
        !            45: # given as arguments.  If the host status is OK, it will batch up at most
        !            46: # ten batches and queue them to be delivered to the specified site.  The "a."
        !            47: # prefix is for packaging agents not covered by the standard batching and
        !            48: # compression algorithms; if you need it, consult the code for details.
        !            49: # 
        !            50: # It also handles the *.cmd files to specify the transmission method as did
        !            51: # sendbatch and csendbatch.
        !            52: # 
        !            53: # Here are the relevant entries from the System V crontab table; note that
        !            54: # System V has a separate file for each user, so if you don't have this,
        !            55: # you may have to modify them so the invocation UID is correct.  Versions
        !            56: # of cron also differ on the complexity of the expressions permitted; use
        !            57: # this as a guide, not as gospel.
        !            58: # 
        !            59: # 56   19-23,0-7 *     *       1-5     . /usr/lib/news/batcher # daily
        !            60: # 56   *       *       *       0,6     . /usr/lib/news/batcher # weekends
        !            61: # 
        !            62: # These lines cause the batcher to be invoked hourly from 8pm (well, 19:56)
        !            63: # to 8am on weekdays and all day on the weekends.  This causes any queued
        !            64: # news to be sent (assuming it thinks the site is alive and well).  I view
        !            65: # the traffic to my backbone sites as important, so I also deliver to them
        !            66: # during the days on weekdays since they have the CPU horsepower to handle
        !            67: # it.  Here is the crontab entry to do that:
        !            68: # 
        !            69: # 56   8-18    *       *       1-5     sh /usr/lib/news/batcher ncrcae sdcsvax
        !            70: # 
        !            71: # I hope this is useful to you.
        !            72: # 
        !            73: # -- Greg Noel, NCR Rancho Bernardo    [email protected] or [email protected]
        !            74: 
        !            75: sed 's/^X//' <<'SHAR_EOF' >batcher; chmod 644 batcher
        !            76: XNEWS=/usr/lib/news    BATCH=/usr/spool/batch
        !            77: XUUCP=/usr/lib/uucp    SPOOL=/usr/spool/uucp
        !            78: XPATH=$NEWS:/bin:/usr/bin export PATH
        !            79: Xeval `grep TZ= /etc/profile`
        !            80: Xcase $# in
        !            81: X0|1)  Files="-name [abc].$1*" ;;
        !            82: X*)    y="(" Files=""
        !            83: X      for file do Files="$Files $y -name [abc].$file*"; y=-o; done
        !            84: X      Files="$Files )"
        !            85: Xesac
        !            86: Xfor rmt in `find $BATCH -type f $Files -print`
        !            87: Xdo    case $rmt in
        !            88: X      *.cmd)  continue ;;
        !            89: X      *.tmp)  continue ;;
        !            90: X      *.work) rmt=`expr $rmt : "\(.*\).work"`
        !            91: X              if test -f $rmt; then continue; fi ;;
        !            92: X      esac
        !            93: X      site=`expr $rmt : ".*/[abc].\(.*\)"`
        !            94: X      site=`expr $site : "\(......\)" \| $site`
        !            95: X      case $rmt in
        !            96: X      */b.*)  if test -s $rmt.cmd -a -x $rmt.cmd
        !            97: X              then    CMD="batch $rmt 60000 | $rmt.cmd \$flag"
        !            98: X              else    CMD="batch $rmt 60000 | uux - -r -n $site!rnews"
        !            99: X              fi ;;
        !           100: X      */c.*)  if test -s $rmt.cmd -a -x $rmt.cmd
        !           101: X              then    CMD="batch $rmt 100000 | compress -q | $rmt.cmd \$flag"
        !           102: X              else    CMD="batch $rmt 100000 | compress -q | uux - -r -n $site!cunbatch"
        !           103: X              fi ;;
        !           104: X      */a.*)  CMD=`sed -n "s/^$site://p" $NEWS/cmds`
        !           105: X              case "$CMD" in "") echo "OOPS -- no command for $site"
        !           106: X                      continue ;;
        !           107: X              esac ;;
        !           108: X      *)      echo "OOPS -- matched illegal file type!"; continue ;;
        !           109: X      esac
        !           110: X      if test -f $SPOOL/STST.$site
        !           111: X      then    if test ! -s $SPOOL/STST.$site
        !           112: X              then    continue        # Hmmmm....  Info file is null
        !           113: X              fi
        !           114: X              read <$SPOOL/STST.$site status garbage
        !           115: X              case $status in
        !           116: X              3)      flag=no ;;      # already talking
        !           117: X              *)      continue ;;
        !           118: X              esac
        !           119: X      else    flag=yes        # start conversation first time through
        !           120: X      fi
        !           121: X      # Send a maximum of ten batches to remote site
        !           122: X      loops=x
        !           123: X      while test -s $rmt -o -s $rmt.work
        !           124: X      do      eval $CMD
        !           125: X              if test $? -ne 0 -o $loops = xxxxxxxxxx; then break; fi
        !           126: X              case $flag in yes) $UUCP/uucico -r1 & ;; esac
        !           127: X              flag=no loops=x$loops
        !           128: X      done
        !           129: Xdone
        !           130: SHAR_EOF
        !           131: exit 0
        !           132: 
        !           133: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.