#!/usr/bin/perl ##--------------------------------------------------------------------------## ## File: ## $Id: compress-mboxes,v 1.8 2002/09/15 03:33:08 ehood Exp $ ## Description: ## Script to compress older mailbox inorder to save disk space. ##--------------------------------------------------------------------------## ## Copyright (C) 2001-2002 Earl Hood ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA ##--------------------------------------------------------------------------## package MHArc::compress_mboxes; ##--------------------------------------------------------------------------## # BEGIN { die qq/CGI use FORBIDDEN!\n/ if (defined($ENV{'GATEWAY_INTERFACE'})); } my $Dir; BEGIN { $Dir = `dirname $0`; chomp $Dir; } use lib "$Dir/../lib"; # Add relative lib to search path # ##--------------------------------------------------------------------------## # use MHArc::Config; my $config = MHArc::Config->load("$Dir/../lib/config.sh"); # ##--------------------------------------------------------------------------## use Getopt::Long; use MHArc::Util qw( exec_prg usage ); MAIN: { my %opt = ( ); my $clstatus = GetOptions(\%opt, "debug!", "n!", 'help', 'man' ); usage(0) unless $clstatus; usage(1) if $opt{'help'}; usage(2) if $opt{'man'}; my $debug = $opt{'debug'}; my $noact = $opt{'n'}; $MHArc::Util::ECHO_CMDS = $noact || $debug; $MHArc::Util::ECHO_ONLY = $noact; $ENV{'PATH'} = join(':', join('/', $config->{'SW_ROOT'}, 'bin'), '/usr/local/bin', '/bin', '/usr/bin'); # Sanity check on $MBOX_DIR if (! -d $config->{'MBOX_DIR'}) { die qq/ERROR: "/, $config->{'MBOX_DIR'}, qq/" is not a directory!/; } # Call compress-files my @cmd_args = ( '-mbox-mode', ); if ($noact) { push(@cmd_args, '-n'); } if ($debug) { push(@cmd_args, '-debug'); } exec("$Dir/compress-files", @cmd_args, $config->{'MBOX_DIR'}); die qq/exec @_ failed: $?\n/; } # End: MAIN ##---------------------------------------------------------------------------## __END__ =head1 NAME compress-mboxes - Gzip old raw mailbox files =head1 SYNOPSIS compress-mboxes compress-mboxes [options] =head1 DESCRIPTION This program is part of mharc and has the responsibility of gzipping mailbox files that have not been modified in over a month to save disk space. Generally, this program will be invoked automatically from C on a periodic basis. This program will use the C variable from Cmharc-rootE/lib/config.sh> as the root directory to search for mailbox files. Any file matching the following regex, ^\d+(?:-\d+)?$ is considered to be a mailbox file. =head1 OPTIONS =over =item C<-debug> Print out alot of status information. =item C<-help> Print out usage information. =item C<-n> Print the commands that would be executed, but do not execute them. =item C<-man> Print out manpage. =back =head1 FILES =over =item Cmharc-rootE/lib/config.sh> Main configuration file for mharc. =back =head1 NOTES =over =item * This program basically invokes L with the proper arguments to do the actual work. =back =head1 SEE ALSO L =head1 VERSION $Id: compress-mboxes,v 1.8 2002/09/15 03:33:08 ehood Exp $ =head1 AUTHOR Earl Hood, earl@earlhood.com This program is part of the mharc archiving system and comes with ABSOLUTELY NO WARRANTY and may be copied only under the terms of the GNU General Public License, which may be found in the mharc distribution. =cut