wisner@hayes.fai.alaska.edu (Bill Wisner) (08/27/90)
This replacement for "addgroup" allows you to change newsgroup moderation status with "addgroup newsgroup [ym]". Bill Wisner <wisner@hayes.fai.alaska.edu> Gryphon Gang Fairbanks AK 99775 "Remember, some net.personalities are basically insane." -- Karl Lehenbauer <karl@sugar.hackercorp.com> #! /bin/sh # addgroup - add a newsgroup, locally only # # Modified by Bill Wisner, 26 August 1990 # Allow changes of group moderation status to be made with this script. # # You may need to edit the pathname in line 10 to fit your local configuration. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()= . ${NEWSCONFIG-/usr/lib/newsbin/config} PATH=$NEWSCTL/bin:$NEWSBIN/maint:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH umask $NEWSUMASK usage="Usage: $0 groupname {y|n|m|x|=realgroup}" case $# in 2) ;; *) echo "$usage" >&2 ; exit 2 ;; esac case "$1" in */*) echo "$usage" >&2 ; exit 2 ;; esac case "$2" in [ynmx]) ;; =*/*) echo "$usage" >&2 ; exit 2 ;; =*) ;; *) echo "$usage" >&2 ; exit 2 ;; esac already="`egrep -e \"^$1 \" $NEWSCTL/active | awk '{ print $4 }'`" if test " $already" = " $2" then echo "$0: $1 appears to exist already" >&2 exit 1 fi case "$already" in =*) echo "$0: $1 appears to exist already" >&2; exit 2 ;; esac case "$2" in n|=*) if test " $already" != " "; then echo "$0: $1 appears to exist already" >&2; fi; exit 2 ;; esac lock="$NEWSCTL/LOCK" ltemp="$NEWSCTL/L.$$" atemp="$NEWSCTL/A.$$" echo $$ >$ltemp trap "rm -f $ltemp $atemp ; exit 0" 0 1 2 15 while true do if newslock $ltemp $lock then trap "rm -f $ltemp $lock ; exit 0" 0 1 2 15 break fi echo 'news system locked, waiting...' sleep 5 done SENDER=${USER-unknown}@`hostname` if test " $already" = " " then # newsgroup doesn't exist, creating it echo "$1 0000000000 0000000001 $2" >>$NEWSCTL/active mkpdir $NEWSARTS/`echo $1 | tr . /` echo "$1 `getdate now` $SENDER" >>$NEWSCTL/active.times # rn hook echo "newsgroup $1 was created locally by $SENDER." | mail $NEWSMASTER fi if test "$2" = "y" then if test "$already" = "y" then echo "$0: $1 is already unmoderated" >&2 exit 2 fi sed "/^$1 /s/ .$/ y/" <$NEWSCTL/active >$atemp cat $atemp >$NEWSCTL/active echo "newsgroup $1 was changed to unmoderated locally by $SENDER." | mail $NEWSMASTER fi if test "$2" = "m" then if test "$already" = "m" then echo "$0: $1 is already moderated" >&2 exit 2 fi sed "/^$1 /s/ .$/ m/" <$NEWSCTL/active >$atemp cat $atemp >$NEWSCTL/active echo "newsgroup $1 was changed to moderated locally by $SENDER." | mail $NEWSMASTER fi