From sdcsvax!ncr-sd!greg@s3sun.CSS.GOV Mon Feb 3 14:24:25 1986 Received: by seismo.CSS.GOV; Mon, 3 Feb 86 12:48:57 EST Return-Path: Received: by s3sun.CSS.GOV (4.24/s3-5.0) id AA01660; Sun, 2 Feb 86 00:14:55 pst hops=0 From: sdcsvax!ncr-sd!greg.@s3sun.CSS.GOV Received: by sdcsvax.ucsd.edu (5.31/4.41) id AA16013; Sat, 1 Feb 86 23:56:26 PST hops=0 Date: Sat, 1 Feb 86 23:56:26 PST Message-Id: <8602020756.AA16013@sdcsvax.ucsd.edu> To: noscvax!rick@siesmo.ARPA, sdcsvax!s3sun!seismo!rick@s3sun.CSS.GOV Subject: Batcher script for news Status: R : shar: Shell Archiver # Run this text with /bin/sh to create: # batcher # I sent this a few days ago, and haven't gotten a reply. This one is a # revision that incorporates some fixes suggested by some other San Diego # sites that have been running it. Again, lease let me know if it arrives, # otherwise I'll try retransmitting it in a few days. # # This is a script that replaces sendbatch and csendbatch. I recommend it to # you for inclusion in 2.10.3. It has some nice attributes, particularly for # me, where I have a lot of news connections to maintain. The most useful to # me is that the default if no arguments are given is to send to everybody, # so that I don't have to run around modifying crontab all the time -- all # of the maintenance is in news/sys. # # Here are some sample sites from news/sys to show how it works: # # sdcsvax:sd,sdnet,ca,to.sdcsvax::uux - -r -n sdcsvax!rnews # sdcsvax:net,fa,mod,na,usa:F:/usr/spool/batch/c.sdcsvax # ncrcae:net,fa,mod,na,usa,ncr,to.ncrcae:F:/usr/spool/batch/c.ncrcae # local:net,fa,mod,na,usa,ca,sdnet,sd,to.local:F:/usr/spool/batch/b.local # # The name chosen determines the type of transmission; the "b." prefix # causes news to be sent batched and the "c." prefix causes news to be # sent compressed (and batched). # # The batcher works by looking for files in /usr/spool/batch with a prefix # of "[abc]."; if it is invoked with no arguments, it will pick up all such # files, otherwise it only picks up files with those prefixes and the names # given as arguments. If the host status is OK, it will batch up at most # ten batches and queue them to be delivered to the specified site. The "a." # prefix is for packaging agents not covered by the standard batching and # compression algorithms; if you need it, consult the code for details. # # It also handles the *.cmd files to specify the transmission method as did # sendbatch and csendbatch. # # Here are the relevant entries from the System V crontab table; note that # System V has a separate file for each user, so if you don't have this, # you may have to modify them so the invocation UID is correct. Versions # of cron also differ on the complexity of the expressions permitted; use # this as a guide, not as gospel. # # 56 19-23,0-7 * * 1-5 . /usr/lib/news/batcher # daily # 56 * * * 0,6 . /usr/lib/news/batcher # weekends # # These lines cause the batcher to be invoked hourly from 8pm (well, 19:56) # to 8am on weekdays and all day on the weekends. This causes any queued # news to be sent (assuming it thinks the site is alive and well). I view # the traffic to my backbone sites as important, so I also deliver to them # during the days on weekdays since they have the CPU horsepower to handle # it. Here is the crontab entry to do that: # # 56 8-18 * * 1-5 sh /usr/lib/news/batcher ncrcae sdcsvax # # I hope this is useful to you. # # -- Greg Noel, NCR Rancho Bernardo Greg@ncr-sd.UUCP or Greg@nosc.ARPA sed 's/^X//' <<'SHAR_EOF' >batcher; chmod 644 batcher XNEWS=/usr/lib/news BATCH=/usr/spool/batch XUUCP=/usr/lib/uucp SPOOL=/usr/spool/uucp XPATH=$NEWS:/bin:/usr/bin export PATH Xeval `grep TZ= /etc/profile` Xcase $# in X0|1) Files="-name [abc].$1*" ;; X*) y="(" Files="" X for file do Files="$Files $y -name [abc].$file*"; y=-o; done X Files="$Files )" Xesac Xfor rmt in `find $BATCH -type f $Files -print` Xdo case $rmt in X *.cmd) continue ;; X *.tmp) continue ;; X *.work) rmt=`expr $rmt : "\(.*\).work"` X if test -f $rmt; then continue; fi ;; X esac X site=`expr $rmt : ".*/[abc].\(.*\)"` X site=`expr $site : "\(......\)" \| $site` X case $rmt in X */b.*) if test -s $rmt.cmd -a -x $rmt.cmd X then CMD="batch $rmt 60000 | $rmt.cmd \$flag" X else CMD="batch $rmt 60000 | uux - -r -n $site!rnews" X fi ;; X */c.*) if test -s $rmt.cmd -a -x $rmt.cmd X then CMD="batch $rmt 100000 | compress -q | $rmt.cmd \$flag" X else CMD="batch $rmt 100000 | compress -q | uux - -r -n $site!cunbatch" X fi ;; X */a.*) CMD=`sed -n "s/^$site://p" $NEWS/cmds` X case "$CMD" in "") echo "OOPS -- no command for $site" X continue ;; X esac ;; X *) echo "OOPS -- matched illegal file type!"; continue ;; X esac X if test -f $SPOOL/STST.$site X then if test ! -s $SPOOL/STST.$site X then continue # Hmmmm.... Info file is null X fi X read <$SPOOL/STST.$site status garbage X case $status in X 3) flag=no ;; # already talking X *) continue ;; X esac X else flag=yes # start conversation first time through X fi X # Send a maximum of ten batches to remote site X loops=x X while test -s $rmt -o -s $rmt.work X do eval $CMD X if test $? -ne 0 -o $loops = xxxxxxxxxx; then break; fi X case $flag in yes) $UUCP/uucico -r1 & ;; esac X flag=no loops=x$loops X done Xdone SHAR_EOF exit 0