2 ##--------------------------------------------------------------------------##
4 ## $Id: gc-search-indexes,v 1.6 2002/09/15 03:33:08 ehood Exp $
6 ## Script to do garbage collection on Namazu search indexes.
7 ##--------------------------------------------------------------------------##
8 ## Copyright (C) 2001-2002 Earl Hood <earl@earlhood.com>
10 ## This program is free software; you can redistribute it and/or modify
11 ## it under the terms of the GNU General Public License as published by
12 ## the Free Software Foundation; either version 2 of the License, or
13 ## (at your option) any later version.
15 ## This program is distributed in the hope that it will be useful,
16 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ## GNU General Public License for more details.
20 ## You should have received a copy of the GNU General Public License
21 ## along with this program; if not, write to the Free Software
22 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 ##--------------------------------------------------------------------------##
26 package MHArc
::compress_mboxes
;
28 ##--------------------------------------------------------------------------##
30 BEGIN { die qq/CGI use FORBIDDEN!\n/ if (defined($ENV{'GATEWAY_INTERFACE'})); }
31 my $Dir; BEGIN { $Dir = `dirname $0`; chomp $Dir; }
32 use lib
"$Dir/../lib"; # Add relative lib to search path
34 ##--------------------------------------------------------------------------##
37 my $config = MHArc
::Config
->load("$Dir/../lib/config.sh");
39 ##--------------------------------------------------------------------------##
43 use MHArc
::Util
qw( cmd usage );
47 my $clstatus = GetOptions
(\
%opt,
54 usage
(0) unless $clstatus;
55 usage
(1) if $opt{'help'};
56 usage
(2) if $opt{'man'};
58 my $debug = $opt{'debug'};
59 my $noact = $opt{'n'};
61 $ENV{'PATH'} = join(':', join('/', $config->{'SW_ROOT'}, 'bin'),
66 $MHArc::Util
::ECHO_CMDS
= $noact || $debug;
67 $MHArc::Util
::ECHO_ONLY
= $noact;
69 print "PATH=$ENV{'PATH'}\n" if $debug;
71 # Sanity check on $HTML_DIR
72 my $html_dir = $config->{'HTML_DIR'};
74 die qq/ERROR: "/, $html_dir, qq/" is not a directory!/;
76 print qq/HTML_DIR=$html_dir\n/ if $debug;
78 # Get list of possible directories
79 opendir(HTML_DIR
, $html_dir) ||
80 die qq/ERROR: Unable to open "$html_dir" for reading: $!\n/;
81 my @dirs = map { "$html_dir/$_" }
84 (-d
"$html_dir/$_") &&
85 (-e
"$html_dir/$_/NMZ.t") } readdir(HTML_DIR
);
87 # Check that we have something to do
89 print "No search indexes found\n" if $debug;
92 print "Searchable directories:\n\t",
93 join("\n\t", @dirs), "\n" if $debug;
95 # Run garbage collection
96 my @cmd_args = ( '-b' );
98 push(@cmd_args, '-v');
100 push(@cmd_args, '-q');
103 if (cmd
('gcnmz', @cmd_args, $_) != 0) {
104 warn qq/Warning: Command "gcnmz @cmd_args $_" failed: $?\n/;
110 ##---------------------------------------------------------------------------##
115 gc-search-indexes - Garbage collect archive search indexes.
120 gc-search-indexes [options]
124 This program is part of mharc, and has the responsibility of performing
125 garbage collection on archive search indexes.
127 Generally, this program will be invoked automatically from C<cron>
130 This program will use the C<HTML_DIR> variable from
131 C<E<lt>mharc-rootE<gt>/lib/config.sh> as the root directory to search for
140 Print out alot of information on what is going on.
144 Print out usage information.
148 Print the commands that would be executed, but do not execute them.
160 =item C<E<lt>mharc-rootE<gt>/lib/config.sh>
162 Main configuration file for mharc.
172 This program should be invoked occasionally, like once a week. The
173 template crontab provided with mharc provides a useful crontab entry
174 for invoking this program.
180 $Id: gc-search-indexes,v 1.6 2002/09/15 03:33:08 ehood Exp $
184 Earl Hood, earl@earlhood.com
186 This program is part of the mharc archiving system and comes with
187 ABSOLUTELY NO WARRANTY and may be copied only under the terms of
188 the GNU General Public License, which may be found in the mharc