Article View: news.software.nntp
Article #2377Re: Removing newsgroups on an INN server (was Re: Active.times)
From: Tim Rosmus
Date: Fri, 21 Jan 1994 17:48
Date: Fri, 21 Jan 1994 17:48
98 lines
4448 bytes
4448 bytes
In <2hm51qINN8cn@rodan.UU.NET> rsalz@uunet.uu.net (Rich Salz) writes:
>In <BRYAN.94Jan19125036@solstice.jpl.nasa.gov> bryan@solstice.jpl.nasa.gov (Bryan Howard) writes:
>>b) rm -rf ~news/defunct/news/group/name
>Not quite, since removing "news.admin" because "news.admin.misc" was
>created would be bad.
>I want to include such a script in 1.5; it would help if I someone else
>sent me a good one.
> /r$
Well what the heck.... Here's what I use, small, not pretty, but it works.
Toss it, trash it, whatever.
I modified the following lines in .../bin/control/rmgroup to call the following
script for rmgroup messages. For manual use, just use as is.
## Do the work.
#ctlinnd -s rmgroup "$1"
/usr/lib/news/bin/delgroup "$1"
============== CUT =========================
#!/usr/local/bin/perl
die "Usage: delgroup group\n" unless $#ARGV == 0;
$spool = "/usr/spool/news";
$group = $ARGV[0]; # some.news.group
@agrp = split(/\./, $group); # Put each component of group into array.
($spltgrp = $ARGV[0]) =~ tr/\./\//; # translate . -> /
$fullp = $spool . "/" . $spltgrp; #/usr/spool/news/some/news/group
# Remove it from the active file.
print "Removing group ", $group, "\n";
system("/usr/lib/news/bin/ctlinnd rmgroup $group");
print "Removing directory tree for ", $group, "\n";
# cd into the newsgroup if it's there
die "No such directory: $!\n" unless chdir($fullp);
$baseflag = 1; # set for last part of some.news.group
$i = $#agrp; # number of components on newsgroup name
while ($i >= 0) {
$dflag = 0; # directory flag
@dirs = (); # directory array
opendir(OD, ".");
@dirs = readdir(OD); # read all files into array
# Look at each entry in the directory
for ($x = 0; $x <= $#dirs; $x++) {
$_ = $dirs[$x];
next if (/^\.$/ || /^\.\.$/); # skip . and ..
# if there is a subdir in this group, set a flag so we don't
# remove anything else except the files in this group.
if (-d) {
$dflag++;
} else {
# If we're in the last component of the news group, remove
# all files within
# If we've gone up one dir from the base, and there are files
# there, then we're done as this may be another valid group.
if ($baseflag && -f) {
unlink($_);
} else {
exit(0);
}
}
}
closedir(OD);
# if we found subdirs in this newsgroup directory, we're all done.
if ($dflag) {
exit(0);
}
# Go up one.
chdir("..");
# IF we are still at the base component of the group, no directories
# were found in the group, and all files have been removed, then
# go ahead and remove the last component of the group (directory)
#
# If we've gone up one directory from the last, and there are no
# other directories in there, then go ahead and remove it.
if ($baseflag || ($i < $#agrp)) {
print " Removing ", $agrp[$i], "\n";
rmdir($agrp[$i]);
} else {
exit(0);
}
# We'ew now on our way up, so reset the base flag. (first time)
$i--;
$baseflag = 0;
}
--
Internet: <tim@mdd.comm.mot.com> | Tim Rosmus (Sys Analyst)
Motorola-X400-ID: <ctr001@email.mot.com> | Motorola - Wireless Data Group
UUCP: <....uunet!mdisea!tim> | 19807 North Creek Parkway
FAX: < 206 - 487 - 5800 > | Bothell, WA USA (206) 487-5928
Technical Details
Message-ID:
<2hp4gl$351@sylvester.mdd.comm.mot.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!xlink.net!rz.uni-karlsruhe.de!news.uni-stuttgart.de!news.belwue.de!surz03.hrz.Uni-Marburg.DE!news.th-darmstadt.de!math.fu-berlin.de!umn.edu!news-feed-2.peachnet.edu!emory!europa.eng.gtefsd.com!uunet!mdisea!not-for-mailReferences:
<2hk37f$mv5@nermal.cs.uoguelph.ca> <BRYAN.94Jan19125036@solstice.jpl.nasa.gov> <2hm51qINN8cn@rodan.UU.NET>Show Full Headers
Complete Article Headers
Message-ID: <2hp4gl$351@sylvester.mdd.comm.mot.com> Subject: Re: Removing newsgroups on an INN server (was Re: Active.times) Date: Fri, 21 Jan 1994 17:48:05 +0000 From: tim@mdd.comm.mot.com (Tim Rosmus) References: <2hk37f$mv5@nermal.cs.uoguelph.ca> <BRYAN.94Jan19125036@solstice.jpl.nasa.gov> <2hm51qINN8cn@rodan.UU.NET> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!xlink.net!rz.uni-karlsruhe.de!news.uni-stuttgart.de!news.belwue.de!surz03.hrz.Uni-Marburg.DE!news.th-darmstadt.de!math.fu-berlin.de!umn.edu!news-feed-2.peachnet.edu!emory!europa.eng.gtefsd.com!uunet!mdisea!not-for-mail Newsgroups: news.software.nntp,news.software.readers Organization: Motorola - Wireless Data Group; Seattle, WA Lines: 98 Distribution: inet NNTP-Posting-Host: sylvester.mdd.comm.mot.com X-Newsreader: NN version 6.5.0 #6 (NOV)