Path: utzoo!utstat!news-server.csri.toronto.edu!torsqnt!lethe!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Newsgroups: news.software.b Subject: Re: C News newgroup handling Message-ID: <1990Oct30.043029.15164@druid.uucp> Date: 30 Oct 90 04:30:29 GMT References: <1990Oct26.173215.17486@druid.uucp> Organization: D'Arcy Cain Consulting, West Hill, Ontario Lines: 166 In article <1990Oct26.173215.17486@druid.uucp> I wrote: >I have been trying to figure out some way to do the following; Every >new/rmgroup message is mailed to user usenet so that replies get sent to >an alias for a process which does the actual newgroup or rmgroup. That >way I just read my mail and when I see a valid control message I just press >'r' to reply with the text included. Bogus messages just get a 'd' and >don't get processed. I don't know when I will get a chance to do this but >any suggestions in the mean time are welcome. Well I finished this. What happens is that I cause every newgroup and rmgroup to be mailed to NEWSMASTER. I then save any approved messages to a folder. I use 'g' as a folder name because I'm lazy. There is a script that reads a file and looks for lines that start with Control and newgroups or rmgroups as necessary. The last piece is the cron entry to run the second script on the folder. Local tests work fine. I'm just waiting for some real world examples to try out. (Where's all those newgroup/rmgroup wars when you need them.) The two scripts consist of a total of ~120 lines mostly stolen from other parts of C News. I think it is small enough to post here so here it is. Note that this is for C News. Perhaps someone familiar with B News can modify it and repost if necessary. The first file replaces both newgroup and rmgroup in $NEWSBIN/ctl ------------------------ start of newgroup/rmgroup --------------- #! /bin/sh # rmgroup group - snuff group # newgroup group flag - create group (4-field version: B-2.10.3+ compatible) # subject to our sys file group pattern # This program checks to see if there is an approved header and if so simply # sends the message as mail to NEWSMASTER. # =()<. ${NEWSCONFIG-@@}>()= . ${NEWSCONFIG-/usr/lib/news/bin/config} export NEWSCTL NEWSBIN NEWSARTS PATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH export PATH umask $NEWSUMASK tmp=/tmp/ng$$ trap "rm -f $tmp.1 $tmp.2; exit 0" 0 cat > $tmp.1 canonhdr < $tmp.1> $tmp.2 # unapproved ctl msg? then quit egrep '^Approved:' $tmp.2 >/dev/null || { rm -f $tmp.1 $tmp.2; exit 0; } mailx -s "$0 requested" $NEWSMASTER < $tmp exit 0 ------------------------ end of newgroup/rmgroup ------------------------- The next file is the script that does the actual newgroup or rmgroup as the case may be. It doesn't matter where you put it as it is only ever called by cron and you have to put an explicit path anyway. ----------------------- start -f do.new.rm ------------------------ #! /bin/sh # newgroup group flag - create group (4-field version: B-2.10.3+ compatible) # subject to our sys file group pattern # =()<. ${NEWSCONFIG-@@}>()= . ${NEWSCONFIG-/usr/lib/news/bin/config} export NEWSCTL NEWSBIN NEWSARTS PATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH # include mkpdir umask $NEWSUMASK mail=/tmp/mail$$ tmp=/usr/tmp/ng$$ if [ ! -r $1 ] then exit 0 fi trap "rm -f $mail $tmp; exit 0" 0 mv $1 $tmp grep '^Control: ' $tmp | while read ctl_message do set $ctl_message greppat="^`echo $3 | sed 's/\./\\\\./g' ` " case $2 in newgroup) if grep -s "$greppat" $NEWSCTL/active >/dev/null; then echo "Newsgroup $3 already exists" >> $mail chamod "$3" "$4" # change moderated flag if needed else me="`newshostname`" gngppat=`awk -f $NEWSBIN/relay/canonsys.awk $NEWSCTL/sys | egrep "^($me|ME):" | awk -F: ' { fields = split($2, field2, "/") # split ngs/dists print field2[1] # print only ngs exit }' ` if gngp -a "$gngppat" >/dev/null <>$NEWSCTL/active (echo "$3 `getdate now` $NEWSMASTER" >>$NEWSCTL/active.times) # rn hook # make the directory since rn will bitch if it's missing mkpdir $NEWSARTS/`echo $3 | tr . / ` echo "newsgroup $3 was created." >> $mail fi fi ;; rmgroup) already="`sed 's/[ ].*//' $NEWSCTL/active | fgrep -x \"$3\"`" if test " $already" = " " then echo "$0: $3 appears not to exist" >> $mail else lock="$NEWSCTL/LOCK" ltemp="$NEWSCTL/L.$$" echo $$ >$ltemp 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 cd $NEWSCTL awk "\$1 != \"$3\"" active >active.tmp mv active active.old && mv active.tmp active chmod 664 active* chown news active* echo "newsgroup $3 was removed. You may wish to rmdir" >> $mail echo "$NEWSARTS/`echo "$3" | sed 's;\.;/;g'` at some point." >> $mail fi ;; esac echo >> $mail done mailx -s "Newgroup/rmgroup activity report" $NEWSMASTER < $mail -------------------------- end of do.new.rm ----------------------------- Now just put a cron entry like the following. I can't think of any way of using anything except root cron since it needs to access files of more than one user, news and whoever usenet is. 28 0,8,16 * * * /usr/lib/newsbin/do.new.rm /usr/darcy/Mail/g -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | I support gun control. West Hill, Ontario, Canada | Let's start with the government! + 416 281 6094 |