PRINTF_FUNCTION -> ALMOST_PRINTF.
[exim.git] / configs / config.samples / S002
CommitLineData
e0f3765a
PH
1From: John Jetmore <jetmore@cinergycom.com>
2Date: Wed, 24 Sep 2003 13:12:58 -0500 (CDT)
3
4I'm sure that everyone who's interested in something like this has already
5come up with their own way to do this, but here's my solution:
6
7When I moved from smail to exim I built a program that took individual
8config pieces stripped all the comments and built a config file. As a
9bonus, it also runs exim -C <testfile> -bV on the new file and reports any
10config errors before copying it over the old config. In addition to just
11being familiar in general w/ all the files being broken up according to
12their major categories, I also got the benfit of being able to have config
13pieces that were easily updatable (just replace the whole file and rebuild
14the configure file).
15
16The script has some site-specific stuff hard coded, but it's easily
17fixable. Essentially in my exim configd I have a directory called
18subconfigure, which can contain directories named \d\d.\w+. Mine
19currently contains:
2010.general/ 30.routers/ 50.retry/ 70.authenticators/
2120.acls/ 40.transports/ 60.rewrite/ 80.local_scan/
22
23Each of these directories can contain files in the form \d\d.\w+. For
24instance, my 30.routers contains:
2500.begin 80.l_user_delivery_normal _50.l_mx
2610.r_forcepaths _12.r_static_route_junk _60.l_psp
2715.r_stalemail _17.r_internal_route _72.l_aliases_list
2833.r_mailrtrd_router _20.r_conditionalforce _74.l_aliases_isp
2940.r_standard _31.r_mailrtrd_bypass_spam _76.l_aliases_mer
3070.l_aliases _39.r_smarthost _80.l_user_delivery_isp
31
32those files prefixed by "_" will not be used to build the live configure
33file. They are "turned off". This allows me to keep a general list of
34configure pieces that are easily updatable but not necessarily every rule
35is used on every machine. Not every file contains a single router - for
36instance 60.l_psp is our virtual hosting solution and contains 10 routers.
37They're just grouped by logical role.
38
39All of these sub pieces are built in to the configure file w/ a shell
40script called mkconfigure, inline below. Again, my assumption is that
41anyone who wants a system like this built it for themselves, but it
42would be kind of fun to flesh this script out to be more generic.
43Maybe post it and some samples on a webpage. Or no one responds to this
44and I shut up about it =).
45
46This system is way overkill for some people (for instance, my home machine
47uses a single configure file because I don't do that much special with
48it), but it's useful in a larger system role.
49
50--John
51
52mkconfigure:
53
54#!/bin/ksh
55
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.
62
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
65# program
66
67# jetmore 20011119
68
69EXIMD=$1
70CONFIGSUFF=$2
71
72if [ "X$EXIMD" == "X" ] ; then
73 EXIMD=/local/exim
74fi
75if [ ! -d "$EXIMD" ] ; then
76 echo "$EXIMD is not a directory" >&2
77 exit 1
78fi
79ETCD=$EXIMD/etc
80SUBCD=$ETCD/subconfigure$CONFIGSUFF
81CONFIGF=$ETCD/configure$CONFIGSUFF
82
83if [ ! -d $SUBCD ] ; then
84 echo "$SUBCD is not a directory" >&2
85 exit 1
86fi
87
88GREP=/bin/grep
89
90# initialize the temporary config file in case some trash got left around
91cat /dev/null > $CONFIGF.t
92
93# print the banner to the temp config file
94echo >> $CONFIGF.t
95echo "#########################################################" >> $CONFIGF.t
96echo "# DO NOT DIRECTLY MANIPULATE THIS FILE " >> $CONFIGF.t
97echo "# " >> $CONFIGF.t
98echo "# if you need to make configuration change, do so in " >> $CONFIGF.t
99echo "# $SUBCD and run the mkconfigure" >> $CONFIGF.t
100echo "# command. Changes made to this file will be lost " >> $CONFIGF.t
101echo "# " >> $CONFIGF.t
102echo "# See jetmore w/ questions " >> $CONFIGF.t
103echo "#########################################################" >> $CONFIGF.t
104echo >> $CONFIGF.t
105
106# get the major categories
107for CAT in $SUBCD/[0-9]*
108do
109 # print which category we're in
110 echo >> $CONFIGF.t
111 echo "## major category $CAT" >> $CONFIGF.t
112 echo >> $CONFIGF.t
113
114 # get the subcategories
115 for SUBCAT in $CAT/[0-9]*
116 do
117 # print which sub category we're in
118 echo "## sub category $SUBCAT" >> $CONFIGF.t
119 echo >> $CONFIGF.t
120
121 # place the contents of any non-comment line into the configure file
122 $GREP -v "^ *#" $SUBCAT >> $CONFIGF.t
123 echo >> $CONFIGF.t
124 done
125done
126
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
129if [ "$?" -eq "1" ] ; then
130 #/bin/rm $CONFIGF.t
131 echo
132 echo "There is a problem with the configure file. "
133 echo "moving paniclog to paniclog.mkfail"
134 echo "$CONFIGF.test has details:"
135 echo
136 echo #####################################################################
137 cat $CONFIGF.test
138 echo #####################################################################
139 echo
140 echo "$CONFIGF not changed!"
141 /bin/mv -f /log/exim/paniclog /log/exim/paniclog.mkfail
142 exit 1
143fi
144/bin/rm $CONFIGF.test
145
146/bin/mv $CONFIGF.t $CONFIGF
147echo "$CONFIGF updated successfully."
148echo "Don't forget to HUP the mail daemon"
149exit 0
150