2
# update-exim4.conf(8) - Generate /var/lib/exim4/config.autogenerated
5
# exit immediately if /etc/exim4/exim4.conf exists
6
[ -e /etc/exim4/exim4.conf ] && exit 0
10
UPEX4C_confdir="/etc/exim4"
13
UPEX4C_autoconfigfile=/var/lib/exim4/config.autogenerated
14
UPEX4C_outputfile="${UPEX4C_autoconfigfile}"
18
$0 - Generate exim4 configuration files
20
-v|--verbose - Enable verbose mode, tell about ignored files
21
-h|--help - Show this message
22
--keepcomments - Do not remove comment lines
23
--removecomments - Remove comment lines
24
-o|--output file - write output to file instead of ${UPEX4C_outputfile}
25
-d|--confdir directory - read input from given directory instead of ${UPEX4C_confdir}
31
# pretty-print messages of arbitrary length (no trailing newline)
32
echo "$*" | fold -s -w ${COLUMNS:-80} >&2;
36
TEMP=$(getopt -n update-exim4.conf \
37
-l keepcomments,removecomments,output:,confdir:,help,verbose -- \
40
if test "$?" != 0; then
41
echo "Terminating..." >&2
46
while test "$1" != "--"; do
63
UPEX4C_outputfile="$1"
74
# No non-option arguments allowed.
75
if [ "$#" -ne 0 ]; then
76
echo "No non option arguments ($@) allowed" >&2
81
UPEX4C_confd=$UPEX4C_confdir/conf.d
83
[ -d ${UPEX4C_confd} ] || \
84
{ printf "$0: Error, no ${UPEX4C_confd}, exiting.\n" 1>&2 ; exit 1 ; }
86
[ -d `dirname $UPEX4C_outputfile` ] || \
87
{ printf "$0: Error, missing `dirname $UPEX4C_outputfile`, exiting.\n" 1>&2 ; exit 1 ; }
89
. $UPEX4C_confdir/update-exim4.conf.conf || \
90
{ printf "$0: Error, no $UPEX4C_confdir/update-exim4.conf.conf, exiting.\n" 1>&2 ; exit 1 ; }
92
[ "x${CFILEMODE}" = "x" ] && CFILEMODE=644
94
mailname=`cat /etc/mailname | head -n 1`
96
# add localhost and mailname, get rid of spaces and trailing colons
97
local_domains="`echo ${mailname}:localhost:${dc_other_hostnames} | \
98
sed -e 's�[: ]*$��' -e 's� *��'`"
100
UPEX4C_internal_tmp=`tempfile -m600 -p ex4`
102
trap "rm -f ${UPEX4C_internal_tmp}" EXIT INT TERM
105
touch ${UPEX4C_outputfile}.tmp
106
chown root:Debian-exim ${UPEX4C_outputfile}.tmp
107
[ -e ${UPEX4C_outputfile} ] && chown root:Debian-exim ${UPEX4C_outputfile}
108
chmod 640 ${UPEX4C_outputfile}.tmp
109
[ -e ${UPEX4C_outputfile} ] && chmod 640 ${UPEX4C_outputfile}
113
if [ "x${UPEX4C_comments}" = "xno" ] ; then
114
grep -E -v '^[[:space:]]*#' ;
120
. /etc/exim4/exim4.conf.defaults
122
case "${listenonpublic}" in
124
listenonpublic='local_interfaces = 127.0.0.1'
127
listenonpublic='# if local_interfaces is unset, we listen on all interfaces'
131
cat << EOF > ${UPEX4C_outputfile}.tmp
133
# WARNING WARNING WARNING
134
# WARNING WARNING WARNING
135
# WARNING WARNING WARNING
136
# WARNING WARNING WARNING
137
# WARNING WARNING WARNING
138
# this file is generated dynamically
139
# Any changes you make here will be lost.
140
# WARNING WARNING WARNING
141
# WARNING WARNING WARNING
142
# WARNING WARNING WARNING
143
# WARNING WARNING WARNING
144
# WARNING WARNING WARNING
148
cat /etc/exim4/exim4.conf.source | \
150
sed -e "s�DEBCONFlocal_domainsDEBCONF�@:${local_domains}�g" \
151
-e "s�DEBCONFrelay_domainsDEBCONF�${relay_domains}�g" \
152
-e "s�DEBCONFrelay_netsDEBCONF�${relay_nets}�g" \
153
-e "s�DEBCONFvisiblenameDEBCONF�${mailname}�g" \
154
-e "s�DEBCONFreadhostDEBCONF�${readhost}�g" \
155
-e "s�DEBCONFsmarthostDEBCONF�${smarthost}�g" \
156
-e "s�DEBCONFconfigtypeDEBCONF�${eximconfig_configtype}�g" \
157
-e "s�DEBCONFlistenonpublicDEBCONF�${listenonpublic}�g" \
158
>> ${UPEX4C_outputfile}.tmp
160
# test validity if called without -o
161
if [ "x${UPEX4C_outputfile}" = "x${UPEX4C_autoconfigfile}" ] ; then
162
if ! ${EXIM} -C "${UPEX4C_outputfile}.tmp" -bV > /dev/null ; then
163
errormessage "Invalid new configfile ${UPEX4C_outputfile}.tmp"
164
errormessage "not installing ${UPEX4C_outputfile}.tmp to ${UPEX4C_outputfile}"
169
mv -f ${UPEX4C_outputfile}.tmp ${UPEX4C_outputfile}