home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1492 / newgroup next >
Encoding:
Text File  |  1990-12-28  |  1.4 KB  |  52 lines

  1. #! /bin/sh
  2. # newgroup group flag
  3. #    subject to our sys file group pattern
  4. #
  5. # Modified by Chip Salzenberg, 7 June 1990.
  6. # Send mail to Usenet administrator describing the newgroup request.
  7. # But if group already exists with correct type, don't bother.
  8.  
  9. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  10. . ${NEWSCONFIG-/usr/lib/news/bin/config}
  11. export NEWSCTL NEWSBIN NEWSARTS
  12. PATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH # include mkpdir
  13. umask $NEWSUMASK
  14.  
  15. afile=/tmp/ncd
  16. afilehdr=/tmp/ncdhdr
  17. afilebody=/tmp/ncdbody
  18. hdr=/tmp/nc$$
  19.  
  20. trap "exit 1" 1 2 3 13 15
  21. trap "rm -f $hdr $afile $afilehdr $afilebody; exit 0" 0
  22.  
  23. $NEWSBIN/inject/tear $afile
  24. $NEWSBIN/canonhdr <$afilehdr >$hdr
  25.  
  26. # unapproved ctl msg? then quit
  27. grep -s '^Approved:' $hdr >/dev/null || { rm -f $hdr; exit 0; }
  28.  
  29. # quit if the group already exists in the form requested
  30. pat="^`echo $1 | sed 's/\./\\\\./g'` "
  31. case `awk "/$pat/ { print \\$4; exit }" $NEWSCTL/active` in
  32. x|=*)    exit 0 ;;
  33. y)    test "" = "$2" && exit 0 ;;
  34. m)    test "moderated" = "$2" && exit 0 ;;
  35. esac
  36.  
  37. SENDER="`grep '^Sender:' $hdr | sed 's/^[^:]*: *//'`"
  38. case "$SENDER" in
  39. "")    SENDER="`grep '^From:' $hdr | sed 's/^[^:]*: *//' `" ;;
  40. esac
  41.  
  42. # tell the local usenet administrator to do it by hand
  43. case "$2" in
  44. "")    G="$1" ;;
  45. *)    G="$1 $2" ;;
  46. esac
  47. ( echo "$SENDER says"
  48.   echo "to create the group '$G',"
  49.   echo "and adds this comment:";
  50.   cat $afilebody ) |
  51.     mail -s "newgroup $G" $NEWSMASTER
  52.