Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

db/active の再構築

  1. 次のスクリプトを makeactive.pl とでもして保存。chmod 755 makeactive.pl。
#!/usr/bin/perl -w

sub numbercomp { $a <=> $b }

my %newsgroups;

while (my $line = <>) {
   next unless $line =~ /\d+$/;
   $line =~ m|articles/(.+)/(\d+)$|;
   my ($ngname, $number) = ($1, $2);
   $ngname =~ s|/|.|g;
   $newsgroups{$ngname}->{$number} = 1;   # raise a flag
}

while (my ($ngname, $numtable) = each %newsgroups) {
   next if $ngname =~ /^$/;
   my @numbers = sort numbercomp keys(%$numtable);
   printf("%s %010d %010d y\n", $ngname, $numbers[$#numbers], $numbers[0]);
}
  1. find /var/spool/news/articles/ | ./makeactive.pl | sort > active.new とでもして、保存されている記事から新しい active ファイルを作る。
  2. 古い active ファイル active.old を持ってきて cat active.old | grep -v cclub とし、結果を active.new に追加。control.cancel や junk newsgroup が追加される。
  3. cat active.old | grep -v "y$" として、フラグが y でない(主にモデレータ付きの) newsgroup をリストアップ。active.new に手動で変更を加える。
  4. できあがった active.new を news/db/active とする。

……で、できあがりのはず。