lists.def blocks http mboxes, unused otherwise
[mharc.git] / bin / read-mail
CommitLineData
2ea8f66b
IK
1#!/usr/bin/perl
2##--------------------------------------------------------------------------##
3## File:
4## $Id: read-mail,v 1.10 2002/09/15 03:33:08 ehood Exp $
5## Description:
6## Read mail spool and archive messages.
7##--------------------------------------------------------------------------##
8## Copyright (C) 2001 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::read_mail;
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( ch_dir cmd usage );
44
45MAIN: {
46 # Grap command-line options
47 my %opt = ( );
48 my $clstatus = GetOptions(\%opt,
49 'force!',
50 'home=s',
51 'verbose!',
52
53 'help',
54 'man',
55 );
56 usage(0) unless $clstatus;
57 usage(1) if $opt{'help'};
58 usage(2) if $opt{'man'};
59
60 my $verbose = $opt{'verbose'};
61 if ($verbose) {
62 $MHArc::Util::ECHO_CMDS = 1;
63 }
64
65 my $home = $opt{'home'} ||
66 $config->{'SW_ROOT'} ||
67 "$Dir/..";
68 my $force = $opt{'force'};
69
70 ch_dir($home) ||
71 die qq/ERROR: Unable to change directory to "$home": $!\n/;
72
73 if (-e '.noarchive') {
74 print "Archiving is currently disabled\n" if $verbose;
75 if (!$force) {
76 exit 0;
77 }
78 print "However, -force specified, so continuing...\n" if $verbose;
79 }
80
81 my @cmd_args = ();
82 push(@cmd_args, '-verbose') if $verbose;
83 if (cmd('./bin/filter-spool', @cmd_args) == 0) {
84 cmd('./bin/web-archive', @cmd_args);
85 }
86}
87
88##---------------------------------------------------------------------------##
89__END__
90
91=head1 NAME
92
93read-mail - Archive incoming mail
94
95=head1 SYNOPSIS
96
97 read-mail
98 read-mail [options]
99
100=head1 DESCRIPTION
101
102This program is part of mharc and is the main program for archiving
103mail. It is generally called via cron.
104
105This program does very little itself, but it invokes other mharc
106scripts to do all the work.
107
108If the file C<.noarchive> exists in mharc root directory, then this
109program will do nothing and exit (unless the C<-force> option is
110specified). This is to allow one to disable incoming mail processing
111while performing administrative tasks.
112
113=head1 OPTIONS
114
115This program is generally called without any command-line options
116since it will read C<E<lt>mharc-rootE<gt>/lib/config.sh> for any configurable
117options. Regardless, the following command-line options are
118available:
119
120=over
121
122=item C<-help>
123
124Print out usage information.
125
126=item C<-home> I<pathname>
127
128Root pathname of archiving software and data. If not specified,
129C<SW_ROOT> variable in C<config.sh> is used, else the parent directory
130that contains this program is used.
131
132=item C<-man>
133
134Print out entire manpage.
135
136=item C<-verbose>
137
138Print out status messages.
139
140=back
141
142=head1 FILES
143
144=over
145
146=item C<I<mharc-root>/lib/config.sh>
147
148Main configuration file for mharc.
149
150=back
151
152=head1 VERSION
153
154$Id: read-mail,v 1.10 2002/09/15 03:33:08 ehood Exp $
155
156=head1 AUTHOR
157
158Earl Hood, earl@earlhood.com
159
160This program is part of the mharc archiving system and comes with
161ABSOLUTELY NO WARRANTY and may be copied only under the terms of
162the GNU General Public License, which may be found in the mharc
163distribution.
164
165=cut
166