tih@barsoom.nhh.no (Tom Ivar Helbekkmo) (10/25/90)
zeeff@b-tech.ann-arbor.mi.us (Jon Zeeff) writes: >echo addgroup $1 $2 >> /usr/lib/news/new.groups >exit 0 Works, sort of. Mine sends me the same message, including the originator of the newgroup, as email. However, I'd like to have newgroup check for changes in 'moderated' state, and properly inform me of what I should do. Anyone who is a better csh programmer than me have something good? -tih -- Tom Ivar Helbekkmo, NHH, Bergen, Norway. Telephone: +47-5-959205 tih@barsoom.nhh.no, thelbekk@norunit.bitnet, edb_tom@debet.nhh.no
darcy@druid.uucp (D'Arcy J.M. Cain) (10/27/90)
In article <1990Oct25.124116.18683@barsoom.nhh.no> Tom Ivar Helbekkmo writes: >zeeff@b-tech.ann-arbor.mi.us (Jon Zeeff) writes: >>echo addgroup $1 $2 >> /usr/lib/news/new.groups >>exit 0 >Works, sort of. Mine sends me the same message, including the originator >of the newgroup, as email. However, I'd like to have newgroup check >for changes in 'moderated' state, and properly inform me of what I should >do. Anyone who is a better csh programmer than me have something good? 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. -- 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 |
jmaynard@thesis1.hsch.utexas.edu (Jay Maynard) (10/27/90)
In article <1990Oct26.173215.17486@druid.uucp> darcy@druid.uucp (D'Arcy J.M. Cain) writes: >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. This sounds like a job for...DELIVER! I haven't looked at this yet, but it seems that you could have $NEWSBIN/ctl/newgrp and /rmgrp send mail to usenet with a reply-to; the deliver.sys file for the reply-to (call it newsaction) would split out the body of the message, set up necessary environment, and feed it to sh. This would be kinda like the B news checkgroups processor: the message would be a shell script with whatever comments you need, and the only uncommented text would be addgrp commands. -- Jay Maynard, EMT-P, K5ZC, PP-ASEL | Never ascribe to malice that which can jmaynard@thesis1.hsch.utexas.edu | adequately be explained by stupidity. "With design like this, who needs bugs?" - Boyd Roberts
darcy@druid.uucp (D'Arcy J.M. Cain) (10/30/90)
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>@}>()= . ${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>@}>()= . ${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 <<! $3 ! then # no group in active, but sys file likes it: make it case "$4" in moderated) flag=m ;; *) flag=y ;; esac echo "$3 0000000000 0000000001 $flag" >>$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 |
chip@tct.uucp (Chip Salzenberg) (11/02/90)
According to jmaynard@thesis1.hsch.utexas.edu (Jay Maynard): >This sounds like a job for...DELIVER! Of course. Everything is a job for Deliver. :-) >I haven't looked at this yet, but it seems that you could have >$NEWSBIN/ctl/newgrp and /rmgrp send mail to usenet with a reply-to; the >deliver.sys file for the reply-to (call it newsaction) would split out the >body of the message, set up necessary environment, and feed it to sh. I like the approach. An alternative implementation would have newgroup and rmgroup add a specially formatted line to the message. Something like: @addgroup foo.bar y Then the system delivery file, triggered by the Reply-To: address would execute the given command (after checking it for reasonableness, of course). I just might do it... -- Chip Salzenberg at Teltronics/TCT <chip@tct.uucp>, <uunet!pdn!tct!chip> "I've been cranky ever since my comp.unix.wizards was removed by that evil Chip Salzenberg." -- John F. Haugh II
darcy@druid.uucp (D'Arcy J.M. Cain) (11/02/90)
In the above referenced article I posted a pair of scripts to semi-automate the administration of newgroups and rmgroups. The second script has a small bug due to the fact that it is run as root. The mkpdir line should be replaced by the following: dir=$NEWSARTS/`echo $3 | tr . ' ' ` path="" for i in $dir do path=$path/$i if [ ! -d $path ] then mkdir $path fi chown news $path done Sorry about that. -- 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 |
darcy@druid.uucp (D'Arcy J.M. Cain) (11/03/90)
In article <2730597C.39AE@tct.uucp> chip@tct.uucp (Chip Salzenberg) writes: >[...] >I like the approach. An alternative implementation would have >newgroup and rmgroup add a specially formatted line to the message. >Something like: > > @addgroup foo.bar y > >Then the system delivery file, triggered by the Reply-To: address >would execute the given command (after checking it for >reasonableness, of course). > >I just might do it... I just did it. You have probably seen it by now. One big difference though is that rather than use Reply-To I just save the approved message to a folder and have cron check it from time to time to see if there is any work to do. I originally implemented Reply-To myself but replying to a message is a lot more work than just saving it to a folder. At least that is true in Elm. I'm not sure about other mail handlers but I suspect it to be generally true. In my case I just enter "s=g" when I see a control message that I approve of. Works just fine so far. -- 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 |