home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 4 / 4001 / newgroup next >
Encoding:
Text File  |  1991-09-09  |  2.5 KB  |  87 lines

  1. #! /bin/sh
  2. # newgroup group flag
  3. #    subject to our sys file group pattern
  4. #
  5. #----------------------------------------------------------------------------
  6. # READ THIS FIRST:
  7. # Be sure to modify the definition of NEWSCONFIG appropriately.
  8. # Also, if you're on a BSD-derived system, you will probably need to
  9. # change the definition of $MAIL from "mail" to "Mail".
  10. #----------------------------------------------------------------------------
  11. #
  12. # Modified by Chip Salzenberg, 21 November 1990
  13. # Settle "mail" vs. "Mail" with the $MAIL variable.
  14. # Combine all possibilities into one mail statement.
  15. #
  16. # Modified by David C Lawrence, 25 August 1990
  17. # Include whole article.  Fixed testing for change of status.
  18. #
  19. # Modified by Bill Wisner, 23 August 1990
  20. # Properly handle changes in moderation status.
  21. #
  22. # Modified by Chip Salzenberg, 7 June 1990.
  23. # Send mail to Usenet administrator describing the newgroup request.
  24. # But if group already exists with correct type, don't bother.
  25. #
  26.  
  27. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  28. . ${NEWSCONFIG-/usr/lib/news/bin/config}
  29. export NEWSCTL NEWSBIN NEWSARTS
  30. PATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH # include mkpdir
  31. umask $NEWSUMASK
  32.  
  33. MAIL=mail
  34.  
  35. afile=/tmp/ncd
  36. afilehdr=${afile}hdr
  37. afilebody=${afile}body
  38. hdr=/tmp/nc$$
  39.  
  40. trap "exit 1" 1 2 3 13 15
  41. trap "rm -f $hdr $afilehdr $afilebody" 0
  42.  
  43. $NEWSBIN/inject/tear $afile
  44. $NEWSBIN/canonhdr <$afilehdr >$hdr
  45.  
  46. # unapproved ctl msg? then quit
  47. egrep '^Approved:' $hdr >/dev/null || exit 1
  48.  
  49. # quit if the group already exists in the form requested
  50. pat="^`echo $1 | sed 's/[+\.]/\\\\&/g'` "
  51. type=`awk "/$pat/ { print \\$4; exit }" $NEWSCTL/active`
  52.  
  53. case "$type" in
  54. x|=*)    exit 0 ;;
  55. y)    test "" = "$2" && exit 0 ;;
  56. m)    test "moderated" = "$2" && exit 0 ;;
  57. esac
  58.  
  59. # determine who sent the message
  60. SENDER="`grep '^Sender:' $hdr | sed 's/^[^:]*: *//'`"
  61. case "$SENDER" in
  62. "")    SENDER="`grep '^From:' $hdr | sed 's/^[^:]*: *//' `" ;;
  63. esac
  64.  
  65. if test "y" = "$type" -a "moderated" = "$2"; then
  66.     subject="Make $1 moderated"
  67.     killme="change the group '$1' from unmoderated to moderated"
  68. elif test "m" = "$type" -a "moderated" != "$2"; then
  69.     subject="Make $1 unmoderated"
  70.     killme="change the group '$1' from moderated to unmoderated"
  71. else
  72.     subject="Create $1 $2"
  73.     if test "moderated" = "$2"; then
  74.         killme="create the moderated group '$1'"
  75.     else
  76.         killme="create the group '$1'"
  77.     fi
  78. fi
  79.  
  80. ( echo "$SENDER says"
  81.   echo "to $killme"
  82.   echo "in this article:"
  83.   echo "================================================================"
  84.   cat $afilehdr $afilebody ) |
  85.     $MAIL -s "$subject" "$NEWSMASTER"
  86. exit 0
  87.