1 From: John Jetmore <jetmore@cinergycom.com>
2 Date: Wed, 24 Sep 2003 13:12:58 -0500 (CDT)
4 I'm sure that everyone who's interested in something like this has already
5 come up with their own way to do this, but here's my solution:
7 When I moved from smail to exim I built a program that took individual
8 config pieces stripped all the comments and built a config file. As a
9 bonus, it also runs exim -C <testfile> -bV on the new file and reports any
10 config errors before copying it over the old config. In addition to just
11 being familiar in general w/ all the files being broken up according to
12 their major categories, I also got the benfit of being able to have config
13 pieces that were easily updatable (just replace the whole file and rebuild
16 The script has some site-specific stuff hard coded, but it's easily
17 fixable. Essentially in my exim configd I have a directory called
18 subconfigure, which can contain directories named \d\d.\w+. Mine
20 10.general/ 30.routers/ 50.retry/ 70.authenticators/
21 20.acls/ 40.transports/ 60.rewrite/ 80.local_scan/
23 Each of these directories can contain files in the form \d\d.\w+. For
24 instance, my 30.routers contains:
25 00.begin 80.l_user_delivery_normal _50.l_mx
26 10.r_forcepaths _12.r_static_route_junk _60.l_psp
27 15.r_stalemail _17.r_internal_route _72.l_aliases_list
28 33.r_mailrtrd_router _20.r_conditionalforce _74.l_aliases_isp
29 40.r_standard _31.r_mailrtrd_bypass_spam _76.l_aliases_mer
30 70.l_aliases _39.r_smarthost _80.l_user_delivery_isp
32 those files prefixed by "_" will not be used to build the live configure
33 file. They are "turned off". This allows me to keep a general list of
34 configure pieces that are easily updatable but not necessarily every rule
35 is used on every machine. Not every file contains a single router - for
36 instance 60.l_psp is our virtual hosting solution and contains 10 routers.
37 They're just grouped by logical role.
39 All of these sub pieces are built in to the configure file w/ a shell
40 script called mkconfigure, inline below. Again, my assumption is that
41 anyone who wants a system like this built it for themselves, but it
42 would be kind of fun to flesh this script out to be more generic.
43 Maybe post it and some samples on a webpage. Or no one responds to this
44 and I shut up about it =).
46 This system is way overkill for some people (for instance, my home machine
47 uses a single configure file because I don't do that much special with
48 it), but it's useful in a larger system role.
56 # I have found that our custom set up of exim's configure file is overly
57 # confusing. To help alleviate this, I have broken the file out into its
58 # core pieces (general, tansports, directors, routers, retry, rewrite, and
59 # authentication), and then each of those into logical sub-pieces (SIS,
60 # for instance. This program is to take all of those sub pieces and put
61 # them back together into the file that exim understands.
63 # No one should every touch the 'configure' file from now on, one should
64 # instead manipulate the files in the subconfigure directory and run this
72 if [ "X$EXIMD" == "X" ] ; then
75 if [ ! -d "$EXIMD" ] ; then
76 echo "$EXIMD is not a directory" >&2
80 SUBCD=$ETCD/subconfigure$CONFIGSUFF
81 CONFIGF=$ETCD/configure$CONFIGSUFF
83 if [ ! -d $SUBCD ] ; then
84 echo "$SUBCD is not a directory" >&2
90 # initialize the temporary config file in case some trash got left around
91 cat /dev/null > $CONFIGF.t
93 # print the banner to the temp config file
95 echo "#########################################################" >> $CONFIGF.t
96 echo "# DO NOT DIRECTLY MANIPULATE THIS FILE " >> $CONFIGF.t
97 echo "# " >> $CONFIGF.t
98 echo "# if you need to make configuration change, do so in " >> $CONFIGF.t
99 echo "# $SUBCD and run the mkconfigure" >> $CONFIGF.t
100 echo "# command. Changes made to this file will be lost " >> $CONFIGF.t
101 echo "# " >> $CONFIGF.t
102 echo "# See jetmore w/ questions " >> $CONFIGF.t
103 echo "#########################################################" >> $CONFIGF.t
106 # get the major categories
107 for CAT in $SUBCD/[0-9]*
109 # print which category we're in
111 echo "## major category $CAT" >> $CONFIGF.t
114 # get the subcategories
115 for SUBCAT in $CAT/[0-9]*
117 # print which sub category we're in
118 echo "## sub category $SUBCAT" >> $CONFIGF.t
121 # place the contents of any non-comment line into the configure file
122 $GREP -v "^ *#" $SUBCAT >> $CONFIGF.t
127 # check and make sure there aren't any typos in the new config file
128 $EXIMD/bin/exim -C $CONFIGF.t -bV > $CONFIGF.test 2>&1
129 if [ "$?" -eq "1" ] ; then
132 echo "There is a problem with the configure file. "
133 echo "moving paniclog to paniclog.mkfail"
134 echo "$CONFIGF.test has details:"
136 echo #####################################################################
138 echo #####################################################################
140 echo "$CONFIGF not changed!"
141 /bin/mv -f /log/exim/paniclog /log/exim/paniclog.mkfail
144 /bin/rm $CONFIGF.test
146 /bin/mv $CONFIGF.t $CONFIGF
147 echo "$CONFIGF updated successfully."
148 echo "Don't forget to HUP the mail daemon"