home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / CNEWS / _CNEWS.TAR / usr / bin / cunbatch next >
Encoding:
Text File  |  1994-09-02  |  1.5 KB  |  64 lines

  1. #! /bin/sh
  2. # Incoming-news spooling.
  3. # We ignore arguments -- it looks tempting to put "$*" after cat and
  4. # newsspool, but there are security problems.
  5.  
  6. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  7. . ${NEWSCONFIG-/var/lib/news/bin/config}
  8.  
  9. PATH=$NEWSCTL/bin:$NEWSBIN/input:$NEWSBIN:$NEWSPATH ; export PATH
  10. umask $NEWSUMASK
  11.  
  12. # check space, assuming a pretty large batch (no cheap way to find real size)
  13. counter=1
  14. while test " `spacefor 250000 incoming`" -le 0
  15. do
  16.     # Warn sysadmin -- he just might be listening and able to act -- and
  17.     # stall a little bit in hopes that it's transient.
  18.     if test " $counter" -eq 1
  19.     then
  20.         (
  21.             echo 'Incoming news will be discarded due to space'
  22.             echo 'shortage unless more room becomes available'
  23.             echo 'within 15 min.'
  24.         ) | mail "$NEWSMASTER"
  25.     fi
  26.     sleep 300
  27.     if test " $counter" -gt 1111        # four tries is plenty
  28.     then
  29.         # oh no! -- nothing we can do, really...
  30.         cat >/dev/null
  31.         echo incoming news discarded due to space shortage >&2
  32.         exit 1
  33.     fi
  34.     if test ! -f $NEWSCTL/rnews.stall
  35.     then
  36.         counter="1$counter"
  37.     else            # avoid repeating the sysadmin warning
  38.         counter=2
  39.     fi
  40. done
  41.  
  42. # spool it
  43. if test -f $NEWSCTL/rnews.immed
  44. then
  45.     opt=-i
  46. else
  47.     opt=
  48. fi
  49. if newsspool $opt >/tmp/ngripe.$$ 2>&1
  50. then
  51.     rm -f /tmp/ngripe.$$
  52.     exit 0
  53. else
  54.     # there really isn't any way to save the data if newsspool fails,
  55.     # not without causing other problems
  56.     (
  57.         echo newsspool failed!!!
  58.         cat /tmp/ngripe.$$
  59.     ) | mail "$NEWSMASTER"
  60.     cat /tmp/ngripe.$$ >&2
  61.     rm -f /tmp/ngripe.$$
  62.     exit 1
  63. fi
  64.