lists.def blocks http mboxes, unused otherwise
[mharc.git] / bin / compress-mboxes
CommitLineData
2ea8f66b
IK
1#!/usr/bin/perl
2##--------------------------------------------------------------------------##
3## File:
4## $Id: compress-mboxes,v 1.8 2002/09/15 03:33:08 ehood Exp $
5## Description:
6## Script to compress older mailbox inorder to save disk space.
7##--------------------------------------------------------------------------##
8## Copyright (C) 2001-2002 Earl Hood <earl@earlhood.com>
9##
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.
14##
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.
19##
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
23## 02111-1307, USA
24##--------------------------------------------------------------------------##
25
26package MHArc::compress_mboxes;
27
28##--------------------------------------------------------------------------##
29# <x-boot-strap>
30BEGIN { die qq/CGI use FORBIDDEN!\n/ if (defined($ENV{'GATEWAY_INTERFACE'})); }
31my $Dir; BEGIN { $Dir = `dirname $0`; chomp $Dir; }
32use lib "$Dir/../lib"; # Add relative lib to search path
33# </x-boot-strap>
34##--------------------------------------------------------------------------##
35# <x-config>
36use MHArc::Config;
37my $config = MHArc::Config->load("$Dir/../lib/config.sh");
38# </x-config>
39##--------------------------------------------------------------------------##
40
41
42use Getopt::Long;
43use MHArc::Util qw( exec_prg usage );
44
45MAIN: {
46 my %opt = ( );
47 my $clstatus = GetOptions(\%opt,
48 "debug!",
49 "n!",
50
51 'help',
52 'man'
53 );
54 usage(0) unless $clstatus;
55 usage(1) if $opt{'help'};
56 usage(2) if $opt{'man'};
57
58 my $debug = $opt{'debug'};
59 my $noact = $opt{'n'};
60
61 $MHArc::Util::ECHO_CMDS = $noact || $debug;
62 $MHArc::Util::ECHO_ONLY = $noact;
63
64 $ENV{'PATH'} = join(':', join('/', $config->{'SW_ROOT'}, 'bin'),
65 '/usr/local/bin',
66 '/bin',
67 '/usr/bin');
68
69 # Sanity check on $MBOX_DIR
70 if (! -d $config->{'MBOX_DIR'}) {
71 die qq/ERROR: "/, $config->{'MBOX_DIR'}, qq/" is not a directory!/;
72 }
73
74 # Call compress-files
75 my @cmd_args = (
76 '-mbox-mode',
77 );
78 if ($noact) {
79 push(@cmd_args, '-n');
80 }
81 if ($debug) {
82 push(@cmd_args, '-debug');
83 }
84 exec("$Dir/compress-files", @cmd_args, $config->{'MBOX_DIR'});
85 die qq/exec @_ failed: $?\n/;
86
87} # End: MAIN
88
89##---------------------------------------------------------------------------##
90__END__
91
92=head1 NAME
93
94compress-mboxes - Gzip old raw mailbox files
95
96=head1 SYNOPSIS
97
98 compress-mboxes
99 compress-mboxes [options]
100
101=head1 DESCRIPTION
102
103This program is part of mharc and has the responsibility of gzipping
104mailbox files that have not been modified in over a month to save
105disk space.
106
107Generally, this program will be invoked automatically from C<cron>
108on a periodic basis.
109
110This program will use the C<MBOX_DIR> variable from
111C<E<lt>mharc-rootE<gt>/lib/config.sh> as the root directory to search for
112mailbox files. Any file matching the following regex,
113
114 ^\d+(?:-\d+)?$
115
116is considered to be a mailbox file.
117
118=head1 OPTIONS
119
120=over
121
122=item C<-debug>
123
124Print out alot of status information.
125
126=item C<-help>
127
128Print out usage information.
129
130=item C<-n>
131
132Print the commands that would be executed, but do not execute them.
133
134=item C<-man>
135
136Print out manpage.
137
138=back
139
140=head1 FILES
141
142=over
143
144=item C<E<lt>mharc-rootE<gt>/lib/config.sh>
145
146Main configuration file for mharc.
147
148=back
149
150=head1 NOTES
151
152=over
153
154=item *
155
156This program basically invokes L<compress-files|compress-files> with the proper
157arguments to do the actual work.
158
159=back
160
161=head1 SEE ALSO
162
163L<compress-files|compress-files>
164
165=head1 VERSION
166
167$Id: compress-mboxes,v 1.8 2002/09/15 03:33:08 ehood Exp $
168
169=head1 AUTHOR
170
171Earl Hood, earl@earlhood.com
172
173This program is part of the mharc archiving system and comes with
174ABSOLUTELY NO WARRANTY and may be copied only under the terms of
175the GNU General Public License, which may be found in the mharc
176distribution.
177
178=cut
179