1# TLB (List Batcher) config file -*- perl -*-
2# This is a list of all variables set by TLB for your use in the config
3# file, and all variables which are used by TLB.  You are free to set other
4# variables without fear of conflicts with the main program.
5
6# The following variables are set depending on the command line:
7# $opt_a, $opt_b, $opt_c: These are flags; they are either undefined, or 1
8#  if the flag is specified on the command line.  For instance, if -a is
9#  given, $opt_a == 1.
10# $opt_x, $opt_y, $opt_z: these are options corresponding to -x, -y, and
11#  -z.  They take arguments, and may be used for any purpose you wish.
12# $opt_l: if given on the command line, the argument to this option is used
13#  to set the variable $list_name for use in the log output and in
14#  initializing certain defaults.
15
16# Set this to anything to prevent the sending of any mail just in case you
17# forget to specify -d256
18# You _MUST_ turn this off (comment out the line) for normal operation.
19$send_no_mail = 1;
20
21# The file containing the address list
22$address_file = "/path/to/address-list";
23
24# The address list has already been stripped.  If you keep your list of
25# address already stripped of comments (see the mungelist command included
26# with TLB), you can save the expensive stripping process by setting this
27# variable.  If you set this and your addresses are not stripped, things
28# will break quite badly.  At the minimum, sorting will not work and every
29# unstripped address will bounce with an error from the delivering host, so
30# be careful.
31#$stripped_address_list = 1;
32
33# The address list is already sorted.  If you keep your list of address
34# pre-sorted in reverse-domain order (see the mungelist command included
35# with TLB), you can save the possibly expensive sorting process by setting
36# this variable.  If you set this and your address list is not sorted,
37# domain-based batching methods will not work well for the addresses that
38# are out of order.  This has little effect for some batch methods; see the
39# nosort tag in the delivery matrix below for more information and
40# finer-grained control.
41#$sorted_address_list = 1;
42
43# The host we're running on.  The default is the value returned by the perl
44# hostfqdn() function.
45#$local_hostname = "big.host.com";
46
47# The value of the envelope sender.  This is the address that will appear
48# in the UNIX From_ header, and the address to which comforming mail
49# transfer agents will send bounces to.
50# Remember to quote the `@' symbol.
51# The default is owner-$address_file@$local_hostname
52#$sender = "owner-list\@big.host.com";
53
54# The program (with arguments) to call to make LOCAL deliveries.  See the
55# delivery matrix below.
56$mailer = "/usr/sbin/sendmail -bs";
57
58# Should we talk ESMTP to the local mailer?
59#$local_ESMTP = 1;
60
61# The directory where we store our temp files.  Defaults to "/tmp".
62#$tempdir = "/tmp";
63
64# The level of system logging tat will be done.  Higher numbers will log
65# more trivial information.  This defaults to 6.
66#$log_level = 6;
67
68# Should we log routines as they are entered, or only as they exit?  Useful for debugging.
69#$log_entries = 1;
70
71# The delivery matrix:
72#
73# This is somewhat complicated if you aren't familiar with complex perl
74# data structures.  Pay attention; there will be a quiz at the end.
75#
76# The delivery matrix maps addresses to destinations.  The basic structure
77# is a list of hashes.  Each hash in the list (called a destination)
78# consists of a regular expression which matches the addresses that are
79# bound for this destination (the default is all addresses), and a series of
80# optional parameters.  The parameters are:
81#
82# hosts:       a list of host definitions (see below)
83# minseparate: the minimum number of addresses in the same domain that must
84#              be present before those addresses are placed in a separate
85#              batch.
86# maxdomains:  the maximum number of domains allowed in a single batch
87# maxaddrs:    the maximum number of addresses allowed in a single batch
88# numbatches:  the number of batches that will be created
89# nosort:      the address list for this destination will not be sorted
90#              prior to batching.
91# fail:        attempts to connect to this host will fail immediately if
92#              the proper debuging flag is used (for testing)
93#
94
95# If minseparate is present, domains are given separate batches if they
96# appear in enough addresses.  Other addresses are batched in batches of
97# maxdomains domains; if maxdomains is not specified, the default is 10.
98#
99# Only one of (maxdomains, maxaddrs, numbatches) is effective; they take
100# precedence in the order listed.
101#
102# If neither of (minseparate, maxdomains, maxaddrs, numbatches) is
103# specified, a single batch is assumed.
104#
105# Currently numbatches splits the address list up evenly across the number
106# of batches you desire; it does not take into account multiple addresses
107# in the same domain and thus is not as efficient as possible.  If this is
108# a problem, let me know and I'll fix it.
109
110# Note that nosort will render maxdomains and minseparate relatively
111# useless unless the address list was presorted.  For large address lists,
112# presorting should save some time (though this has yet to be measured).
113#
114# Destinations are matched in order, so if a destination with a blank
115# regexp (which defaults to matchine everything) is encountered it will
116# consume all addresses and no further destinations will accumulate any
117# addresses.  There is an implicit destination specified with
118# 'numbatches' => 1 and a host list consisting only of the LOCAL host (see
119# below) which will catch any unmatched addresses.  This permits some means
120# of backwards compatibility; an empty @destination_matrix will deliver one
121# batch of addresses to the default mailer which results in the the same
122# system load and list performance as the normal Majordomo behavior.
123#
124# A host definition is a hash containing the hostname (or IP address,
125# command line, or the string 'LOCAL') and the following optional
126# parameters:
127#
128# port:     the SMTP port on this system
129# timeout:  the connection timeout; if the host does not accept a connection
130#           within this number of seconds it is marked down
131# ESMTP:    a flag; does the host speak ESMTP?
132# ONEX:     a flag; should we send ONEX to prevent server forking?  (This is
133#           Sendmail specific.)
134# backup:   a flag; this is a backup host, batches will not be sent to it
135#            unless another host in the list is not responding.
136#
137# Note: if the hostname is set to 'LOCAL', the default mailer program will
138# be run on the local host instead of an SMTP connection being opened.  If
139# the hostname is set to a string beginning with `/', that string will be
140# passed to exec, thus running an alternate command for mail delivery.  The
141# command must process SMTP on standard input as Sendmail does.  You can
142# use this to specify special Sendmail paramaters like alternate queuing
143# directories, or run a completely different program to handle the
144# delivery.
145#
146# To save typing, I recommend that the hosts be defined elsewhere and
147# included in the hosts array for each destination as hash references (see
148# the example).  This has the advantage that when a host is marked down it
149# is considered to be down in all destinations.
150#
151# If there are multiple batches to be delivered to a hostlist that contains
152# more than one non-backup host, the batches will be split evenly between
153# the hosts.  This allows not only parallelism in delivery on a single
154# host, but parallelism across multiple hosts.
155#
156# If a host fails to respond or the LOCAL host encounters an error, that
157# host will be marked down and all backup hosts for that destination will
158# become active.  In this case, batches will be split evenly among all
159# responding hosts in the hostlist (backups and otherwise).  The hosts
160# marked down will not be consulted again for the duration of the program
161# run.
162
163# Here's a host that supports ESMTP and ONEX; it's usually pretty fast so
164# we timeout after 20 seconds.
165%host1 = (
166	  'hostname' => 'host1.corp.com',
167	  'port'     => 'smtp',
168	  'timeout'  => 20,
169	  'ESMTP'    => 1,
170	  'ONEX'     => 1,
171	 );
172
173# Here's host1 again, but this time it's a backup.  We'll use this in case
174# a remote exploder fails to come up.
175%backup1 = (
176	    'hostname' => 'host1.corp.com',
177	    'port'     => 'smtp',
178	    'timeout'  => 20,
179	    'ESMTP'    => 1,
180	    'ONEX'     => 1,
181	    'backup'   => 1,
182	   );
183
184# Here's a generic host; we take all of the defaults.
185%host2 = (
186	  'hostname' => 'host2.corp.com',
187	 );
188
189# Another host; we use it as a backup.
190%host3 = (
191	  'hostname' => 'host3.corp.com',
192	  'backup'   => 1,
193	 );
194
195# Here's a host across the globe; we'll use it to deliver some far-away
196# addresses.
197%downunder = ('hostname' => 'g.day.mate.au',
198	      'ESMTP'    => 1,
199	     );
200
201# And another for our Scandinavian friends
202%nordland = ('hostname' => 'arctic.air.no');
203
204
205# Now the big business.  We direct remote addresses off to the special
206# destinations and distribute the load between our local hosts for those
207# left over.
208@delivery_matrix = ( {
209		      'regexp'      => 'au$',
210		      'hosts'       => [ \%downunder, \%backup1, ],
211		      'maxdomains'  => 15,
212		     },
213		     {
214		      'regexp'      => '(no|se|fi)$',
215		      # Backups don't have to come at the end
216		      'hosts'       => [ \%backup1, \%nordland, ],
217		      'numbatches'  => 10, # They prefer that we limit the
218                                          # load to ten simultaneous
219                                          # processes
220		     },
221		     {
222		      # Here's the default
223		      'hosts'       => [ \%host1, \%host2, \%host3, ],
224		      'minseparate' => 5,
225		      'maxdomains'  => 10,
226		     },
227		   );
228
229# That's it.  Running TLB with this matrix will: split off the Australian
230# addresses and send them in batches of fifteen domains to an exploder in
231# Australia, split the Scandanavian addresses into ten total batches and
232# send those to a host in Norway, and split the remaining addresses evenly
233# between host1 and host2 with domains appearing 5 or more times in
234# separate batches and other domains batched in groups of ten.  (Whew.)
235# Backup hosts will be used if any of the other hosts do not respond.  If
236# the backup hosts do not respond, the LOCAL host, defined by the $mailer
237# variable, will be executed and used for delivery.  XXX If that fails,
238# currently bad things happen, but we have no other choice.
239
240# External programs:
241#
242# TLB can send the message to a set of external programs.  This takes the
243# place of the extra items often present in outgoing aliases to do message
244# archiving and such.
245#
246# The insructions telling TLB which commands to run are stored in (again) a
247# list of hashes, one hash per external program.  Each has consists of a
248# number of parameters:
249#
250# commandline: the command line that will be exec'd.
251# pipemessage: the message will be provided to the command in standard
252#              input.  TLB automatically prepends a blank line, as Sendmail
253#              does.
254# needsfrom: the From_ line, or UNIX mbox separator, will be prepended to
255#            the message.  If one was not supplied to TLB when it was
256#            invoked, one will be supplied based on the current time and
257#            value of the $sender configuration variable.
258#
259# In addition, the commandline can contain tags which are expanded before
260# the program is executed.  These tags are:
261#
262# =FILE=: the name of the file that contains the message text.  Note that
263#         this file will _not_ have the UNIX mbox separator (or From_
264#         line) prepended.
265#
266# Sorry, that's currently all.  If other tags are required I will be happy
267# to consider adding them.  Note that the programs are executed with the
268# same permissions that TLB was invoked with; this will usually be an
269# account without permissions if called from the mailer, or will be the
270# majordomo user if called from the Majordomo wrapper or directly from
271# resend.
272
273# External programs are disabled by default.
274$send_to_externals = 1;
275
276# Pipe the message, with From_ line, to the majordomo archive program, and
277# send a copy into a temporary log file.
278@external_programs = ( {
279			'commandline' => '/usr/local/majordomo/archive2 -a -m
280                                          -f /usr/local/archive/list/list',
281			'pipemessage' => 1,
282			'needsfrom'   => 1,
283		       },
284		       {
285			'commandline' => 'cat __FILE__ >> /tmp/tlblog'
286		       }
287		     );
288
289#
290# Running TLB:
291#
292# TLB normally takes a single argument, the name of the appropriate config
293# file.  In addition to this, two other options can be specified:
294#
295# -t address
296#   This sends several test messages to address, but uses each host in the
297#   matrix (plus the LOCAL host) do deliver them.  This acts as a test the
298#   matrix and the ability of each host to deliver non-local mail for you.
299#
300# -d number
301#   Turns on one or more special debugging functions.  The following
302#   functions are supported; simply add the ones you want and place the
303#   result after the -d flag:
304#      1    - address lists before sorting
305#      2    - address lists after sorting
306#      4    - batches that will be sent to each host, and batch info
307#      8    - delivery verbosity (important things, errors))
308#      16   - delivery verbosity (less important things, informationals)
309#      32   - SMTP transactions excluding the message test
310#      64   - The escaped mesage text
311#      128  - Open connections, but do not actually send or receive any
312#             data.
313#      256  - Do not open sockets, and send no data
314#      512  - Pay attention to 'fail' tags in hosts descriptions.
315#      1024 - Fail all envelope opens (except to LOCAL) with 50%
316#             probability
317#
318# Note that 256 implies 128, that flags 1, 2, and 4 do nothing in the
319# presence of -t (the address list is never read), and the $send_no_mail
320# variable effectively turns on 256 (and thus 128).  512 and 1024 are for
321# internal testing of TLB fallback mechanisms and aren't really useful for
322# normal testing (unless you're curious).
323#
324# Send questions, comments, additions, etc. to tibbs@hpc.uh.edu.
325
326