whp@cbnap.UUCP (W. H. Pollock x4575 3S235) (10/10/86)
In article <352@catnip.UUCP> ben@catnip.UUCP (Bennett Broder) writes: >... >A word of caution to people using the rmgroup script supplied with 2.10.3 >(and possibly earlier versions) to kill talk.religion: rmgroup will also >wipe out talk.religion.misc. It won't harm the entries in the newsgroups or >active file, but the spool directory and all the articles will go. Although >the spool directory will be recreated next time an article is posted, the >articles previously posted to talk.religion.misc will be gone forever. > >Perhaps rmgroup should be made a little smarter? I was bitten by this once already and I fixed rmgroup simply by changing the "rm -rf" to "rm -f". This is safe, but it doesn't always remove everythig I want it to. What is needed is a script to determine if a directory contains any subdirectories; if so use: rm -f $dir/* otherwise use: rm -rf $dir Below is the script I use (on my Sys V 2.0 3B20 machine). So far it has worked flawlessly. Feel free to use/critisize/improve on this: Wayne H. Pollock, Your Friendly Neighborhood System Administrator UUCP: ...{ihnp4,cbatt}!cbnap!whp DELPHI: WHP GEnie: W.POLLOCK "The opinions expressed above are ficticious. Any resemblance to the opinions of persons living or dead is purely coincidental." --------------------------------cut-here------------------------------------ : '@(#)rmgroup.sh 1.3 8/21/84' for group do echo "Removing newsgroup $group" qgrp="`echo $group | sed 's/\./\\\./g'`" if grep -s "^$qgrp " /usr/lib/news/active then ed - /usr/lib/news/active << E_O_F /^$qgrp /d w q E_O_F dir=/usr/spool/news/"`echo $group | sed 's/\./\//g'`" if [ -d "$dir" ] then x=`find $dir/* -type d -print 2>/dev/null` case "$x" in "") rm -rf $dir ;; *) rm -f "$dir/*" ;; esac else echo "$0: $dir: no spool directory" 2>&1 fi else echo "$0: $group: no such newsgroup" 2>&1 fi done exit 0