summaryrefslogtreecommitdiff
path: root/debian/exim4-config.config
diff options
context:
space:
mode:
Diffstat (limited to 'debian/exim4-config.config')
-rw-r--r--debian/exim4-config.config468
1 files changed, 468 insertions, 0 deletions
diff --git a/debian/exim4-config.config b/debian/exim4-config.config
new file mode 100644
index 0000000..6aa6985
--- /dev/null
+++ b/debian/exim4-config.config
@@ -0,0 +1,468 @@
+#!/bin/sh
+set -e
+
+alias stripwhitespace="sed -e 's/^[[:blank:]]*//' -e 's/[[:blank:]]*$//'"
+
+. /usr/share/debconf/confmodule
+
+
+# store environment variables in debconf db.
+storevar2db() {
+ dc_eximconfig_configtype=`echo "${dc_eximconfig_configtype}" | stripwhitespace`
+ dc_local_interfaces=`echo "${dc_local_interfaces}" | stripwhitespace`
+ dc_other_hostnames=`echo "${dc_other_hostnames}" | stripwhitespace`
+ dc_readhost=`echo "${dc_readhost}" | stripwhitespace`
+ dc_relay_domains=`echo "${dc_relay_domains}" | stripwhitespace`
+ dc_relay_nets=`echo "${dc_relay_nets}" | stripwhitespace`
+ dc_smarthost=`echo "${dc_smarthost}" | stripwhitespace`
+ dc_minimaldns=`echo "${dc_minimaldns}" | stripwhitespace`
+ # store externally changed values to debconf.db
+ db_set exim4/dc_eximconfig_configtype "${dc_eximconfig_configtype}"
+ db_set exim4/dc_local_interfaces "${dc_local_interfaces}"
+ db_set exim4/dc_other_hostnames "${dc_other_hostnames}"
+ db_set exim4/dc_readhost "${dc_readhost}"
+ db_set exim4/dc_relay_domains "${dc_relay_domains}"
+ db_set exim4/dc_relay_nets "${dc_relay_nets}"
+ db_set exim4/dc_smarthost "${dc_smarthost}"
+ if [ "x${dc_minimaldns}" != "x" ]; then
+ db_set exim4/dc_minimaldns "${dc_minimaldns}"
+ fi
+}
+
+# ipv6: replace double colons in colon-separated host lists with umlaut-o
+# replace ':' with ' : ', add leading and ending whitespace.
+# return empty string if custom delimiter was used:
+ # local_domains = <; 172.16.0.0/12; 3ffe:ffff:836f::/48
+# e.g: 'localhost : 172.16.0.1 :3ffe::ffff::836f::::: foo.org'
+# ===> ' localhost : 172.16.0.1 : 3ffeöffffö836föö : foo.org '
+alias coloncolon2oe="sed -e 's/[[:blank:]]*//g' -e '/^</d' -e 's/:::::/:öö/g' -e 's/::::/öö/g' -e 's/:::/:ö/g' -e 's/::/ö/g' -e 's/:/ : /g' -e 's/^/ /' -e 's/$/ /'"
+
+# try to parse exim3 configuration file - works only if it was generated
+# with eximconfig.
+parseexim3() {
+ dc_mailname=`head -1 /etc/mailname | stripwhitespace` || true
+
+ # get the .... entries from
+ # host_accept_relay = 127.0.0.1 : ::::1 : ......
+ # if they exist, ie. parse list, and remove "127.0.0.1", "::::1"
+ # and "localhost" from it.
+ #
+ dc_relay_nets=`cat $1 | grep -h '^host_accept_relay[[:blank:]]*=' | sed -e 's/^host_accept_relay[[:blank:]]*=//' | coloncolon2oe | sed -e 's/ 127\.0\.0\\.1 //g' -e 's/ localhost //g' -e 's/ öö1//g' -e 's/[[:blank:]]*//g' -e 's/::/:/g' -e 's/^://' -e 's/:$//' -e 's/ö/::/g'`
+
+ # 'local_domains = $colonhostnames', including mailname and "localhost"
+ #
+ dc_other_hostnames=`cat $1 | grep -h '^local_domains[[:blank:]]*=' | sed -e 's/^local_domains[[:blank:]]*=//' | coloncolon2oe | sed -e 's/ localhost //g' -e "s/ ${dc_mailname} //g" -e 's/[[:blank:]]*//g' -e 's/::/:/g' -e 's/^://' -e 's/:$//' -e 's/ö/::/g'`
+
+ # relay_domains = some.domain
+ dc_relay_domains=`cat $1 | grep -h '^relay_domains = ' | sed -e 's/^relay_domains[[:blank:]]*=[[:blank:]]*//' -e 's/[[:blank:]]*$//'`
+
+ # lookuphost router exist ---> dc_eximconfig_configtype=internet
+ #
+ if cat $1 | grep -h -A2 '^lookuphost:' | \
+ grep -h -A1 '[[:blank:]]*driver = lookuphost' | \
+ grep -h -q '[[:blank:]]*transport = remote_smtp' ; then
+ dc_eximconfig_configtype=internet
+ else
+ # smart:-director exists ---> dc_eximconfig_configtype=satellite
+ #
+ # Later we need the new_address directive to find dc_readhost.
+ # ' || true' is required for "set -e"
+ dc_readhost=`cat $1 | grep -h -A2 '^smart:' | grep -h -A1 '^[[:blank:]]*driver = smartuser' | grep -h '^[[:blank:]]*new_address' || true`
+
+ # smarthost router exists --> dc_eximconfig_configtype is satellite or smarthost
+ #
+ # we need the route_list directive to find dc_smarthost
+ # ' || true' is required for "set -e"
+ dc_smarthost=`cat $1 | grep -h -A3 '^smarthost:' | grep -h -A2 '[[:blank:]]*driver = domainlist' | grep -h -A1 '^[[:blank:]]*transport = remote_smtp' | grep -h '^[[:blank:]]*route_list = "' || true`
+
+ if [ ! -z "${dc_readhost}" ] ; then
+ dc_eximconfig_configtype=satellite
+ elif [ ! -z "${dc_smarthost}" ] ; then
+ dc_eximconfig_configtype=smarthost
+ elif ! cat "$1" | grep -h -q '^remote_smtp:'; then
+ # dc_eximconfig_configtype=local has no remote_smtp transport.
+ dc_eximconfig_configtype=local
+ else
+ # handcrafted config. We probably misparsed, reset values
+ # and exit.
+ dc_eximconfig_configtype=''
+ dc_local_interfaces='notset'
+ dc_other_hostnames=''
+ dc_readhost=''
+ dc_relay_domains=''
+ dc_relay_nets=''
+ dc_smarthost=''
+ return 1
+ fi
+ fi
+
+ case ${dc_eximconfig_configtype} in
+ internet|local)
+ #paranoia
+ dc_readhost=''
+ dc_smarthost=''
+ ;;
+ satellite)
+ # new_address = ${local_part}@$readhost
+ dc_readhost=`echo "${dc_readhost}" | sed -e 's/^.*@//' -e 's/[[:blank:]]*$//'`
+ # route_list = "* $smtphost bydns_a"
+ dc_smarthost=`echo "${dc_smarthost}" | \
+ sed -e 's/^ *route_list = "\* //' -e 's/ bydns_a"//' -e 's/[[:blank:]]*$//'`
+ ;;
+ smarthost)
+ # route_list = "* $smtphost bydns_a"
+ dc_smarthost=`echo "${dc_smarthost}" | \
+ sed -e 's/^ *route_list = "\* //' -e 's/ bydns_a"//' -e 's/[[:blank:]]*$//'`
+ ;;
+ esac
+}
+
+# set to dummy value, so we can differ between unset vs (seen or set outside debconf)
+dc_local_interfaces=notset
+
+# REMOVEMEBEFORERELEASE begins
+# cruft from renaming debconf.results to update-exim4.conf.conf
+if [ -e /etc/exim4/debconf.results ] && \
+ [ ! -e /etc/exim4/update-exim4.conf.conf ]; then
+ cp -a /etc/exim4/debconf.results /etc/exim4/update-exim4.conf.conf
+fi
+# REMOVEMEBEFORERELEASE ends
+
+db_get exim4/dc_eximconfig_configtype
+dc_eximconfig_configtype="$RET"
+
+if [ -e /etc/exim4/update-exim4.conf.conf ] ; then
+ . /etc/exim4/update-exim4.conf.conf || true
+ # set defaults using these values
+ storevar2db
+else
+ # If there are no debconf answers (running first time) and we are
+ # making a cross upgrade from exim3, try to parse its config file
+ # to seed debconf db.
+ if [ "x${dc_eximconfig_configtype}" = "x" ] && [ -r /etc/exim/exim.conf ] ; then
+ # parse old configfile
+ if parseexim3 /etc/exim/exim.conf ; then
+ # set defaults using these values
+ storevar2db
+ fi
+ fi
+fi
+
+## set up default values, we cannot do this in templates file because
+## config script is called two times before update-exim4.conf.conf exists.
+[ "x${dc_eximconfig_configtype}" = "x" ] && \
+ dc_eximconfig_configtype="local" && \
+ db_set exim4/dc_eximconfig_configtype "${dc_eximconfig_configtype}"
+
+
+if [ -e /etc/mailname ] ; then
+ dc_mailname=`head -1 /etc/mailname | stripwhitespace` || true
+ # store values
+ db_set exim4/mailname "${dc_mailname}"
+else
+ db_get exim4/mailname
+ dc_mailname="$RET"
+fi
+
+#Set default mailname
+if [ "x${dc_mailname}" = "x" ] ; then
+ dc_mailname=`hostname --fqdn` || dc_mailname=`hostname` && \
+ dc_mailname=`echo "${dc_mailname}" | stripwhitespace` && \
+ db_set exim4/mailname "${dc_mailname}"
+fi
+
+# initialize env-vars from debconf_db, if they haven't been set yet either by
+# parseexim3() or by sourcing /etc/exim4/update-exim4.conf.conf
+if [ "x${dc_readhost}" = "x" ] ; then
+ db_get exim4/dc_readhost
+ dc_readhost="$RET"
+fi
+if [ "x${dc_smarthost}" = "x" ] ; then
+ db_get exim4/dc_smarthost
+ dc_smarthost="$RET"
+fi
+# Tricky! An empty value for this option is significant, therefore both
+# envvar and debconf-value default to "nonset" instead of "", the
+# following line will only change then envvars value if the config-script
+# runs the second time without existing /etc/exim4/update-exim4.conf.conf or
+# if the debconf-db has been preseeded by other means.
+if [ "x${dc_local_interfaces}" = "xnotset" ]; then
+ db_get exim4/dc_local_interfaces
+ dc_local_interfaces="$RET"
+fi
+if [ "x${dc_minimaldns}" = "x" ] ; then
+ db_get exim4/dc_minimaldns
+ dc_minimaldns="$RET"
+fi
+
+
+db_version 2.0
+
+db_capb backup
+# initial state
+STATE=1
+# last valid state
+STATELIMIT=30
+while [ "$STATE" != 0 -a "$STATE" -le "$STATELIMIT" ]; do
+ case "$STATE" in
+ 1)
+ db_input medium exim4/mailname || true
+ PREVSTATE=$STATE
+ NEXTSTATE=$(($STATE + 1))
+ ;;
+ 2)
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATE + 1))
+ db_input critical exim4/dc_eximconfig_configtype || true
+ ;;
+ 3)
+ db_get exim4/dc_eximconfig_configtype
+ dc_eximconfig_configtype="$RET"
+ db_get exim4/mailname
+ dc_mailname="$RET"
+ db_subst exim4/dc_other_hostnames mailname ${dc_mailname}
+ PREVSTATE=$(($STATE - 1))
+ case "${dc_eximconfig_configtype}" in
+ none)
+ # dont ask more questions
+ NEXTSTATE=$(($STATELIMIT + 1))
+ ;;
+ internet)
+ NEXTSTATE=7
+ ;;
+ smarthost)
+ NEXTSTATE=14
+ ;;
+ satellite)
+ NEXTSTATE=21
+ ;;
+ local)
+ NEXTSTATE=28
+ ;;
+ *)
+ # Should not happen. Break loop
+ NEXTSTATE=$(($STATELIMIT + 1))
+ ;;
+ esac
+ ;;
+
+ 7)
+ # internet site
+ PREVSTATE=2
+ NEXTSTATE=$(($STATE + 1))
+ if [ "x${dc_local_interfaces}" = "xnotset" ] ; then
+ dc_local_interfaces=''
+ db_set exim4/dc_local_interfaces ''
+ fi
+ db_input medium exim4/dc_local_interfaces || true
+ ;;
+ 8)
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATE + 1))
+ db_input medium exim4/dc_other_hostnames || true
+ ;;
+ 9)
+ db_input medium exim4/dc_relay_domains || true
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATE + 1))
+ ;;
+ 10)
+ db_input medium exim4/dc_relay_nets || true
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATE + 1))
+ ;;
+ 11)
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATELIMIT + 1))
+ db_input low exim4/dc_minimaldns || true
+ ;;
+
+ 14)
+ # internet site with smarthost
+ PREVSTATE=2
+ NEXTSTATE=$(($STATE + 1))
+ if [ "x${dc_local_interfaces}" = "xnotset" ] ; then
+ dc_local_interfaces=''
+ db_set exim4/dc_local_interfaces ''
+ fi
+ db_input medium exim4/dc_local_interfaces || true
+ ;;
+ 15)
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATE + 1))
+ db_input medium exim4/dc_other_hostnames || true
+ ;;
+ 16)
+ db_input medium exim4/dc_relay_domains || true
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATE + 1))
+ ;;
+ 17)
+ db_input medium exim4/dc_relay_nets || true
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATE + 1))
+ ;;
+ 18)
+ if [ "x${dc_smarthost}" = "x" ] ; then
+ # default to mail.mailname
+ dc_smarthost="mail.${dc_mailname}"
+ db_set exim4/dc_smarthost "${dc_smarthost}"
+ fi
+ db_input high exim4/dc_smarthost || true
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATE + 1))
+ ;;
+ 19)
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATELIMIT + 1))
+ db_input low exim4/dc_minimaldns || true
+ ;;
+
+ 21)
+ # satellite
+ PREVSTATE=2
+ NEXTSTATE=$(($STATE + 1))
+ if [ "x${dc_local_interfaces}" = "xnotset" ] ; then
+ dc_local_interfaces='127.0.0.1'
+ db_set exim4/dc_local_interfaces '127.0.0.1'
+ fi
+ db_input medium exim4/dc_local_interfaces || true
+ ;;
+ 22)
+ PREVSTATE=2
+ NEXTSTATE=$(($STATE + 1))
+ db_input medium exim4/dc_other_hostnames || true
+ ;;
+ 23)
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATE + 1))
+ if [ "x${dc_readhost}" = "x" ] ; then
+ # default to domain of mailname
+ dc_readhost=`echo ${dc_mailname} | sed -e 's/^[^.][^.]*\.//'`
+ db_set exim4/dc_readhost "${dc_readhost}"
+ fi
+ db_input high exim4/dc_readhost || true
+ ;;
+ 24)
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATE + 1))
+ db_get exim4/dc_readhost
+ dc_readhost="$RET"
+ if [ "x${dc_smarthost}" = "x" ] ; then
+ # default to read_host
+ dc_smarthost="${dc_readhost}"
+ db_set exim4/dc_smarthost "${dc_smarthost}"
+ fi
+ db_input high exim4/dc_smarthost || true
+ ;;
+ 25)
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATE + 1))
+ # satellite-system! Only ask for relay_nets/relay_domains if they are
+ # nonempty - we cannot distinguish whether they were set outside debconf
+ # or whether the user switched dc_eximconfig_configtype
+ db_get exim4/dc_relay_nets || true
+ dc_relay_nets="$RET"
+ db_get exim4/dc_relay_domains || true
+ dc_relay_domains="$RET"
+ if [ "x${dc_relay_nets}" != "x" ] ; then
+ db_input medium exim4/dc_relay_nets || true
+ NEXTSTATE=$(($STATE + 1))
+ fi
+ if [ "x${dc_relay_domains}" != "x" ] ; then
+ NEXTSTATE=$(($STATE + 1))
+ db_input medium exim4/dc_relay_domains || true
+ fi
+ ;;
+ 26)
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATELIMIT + 1))
+ db_input low exim4/dc_minimaldns || true
+ ;;
+
+ 28)
+ # local mail only
+ PREVSTATE=2
+ NEXTSTATE=$(($STATE + 1))
+ if [ "x${dc_local_interfaces}" = "xnotset" ] ; then
+ dc_local_interfaces='127.0.0.1'
+ db_set exim4/dc_local_interfaces '127.0.0.1'
+ fi
+ db_input medium exim4/dc_local_interfaces || true
+ ;;
+ 29)
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATELIMIT + 1))
+ # local mail only -system! Only ask for relay_nets/relay_domains if they are
+ # nonempty - we cannot distinguish whether they were set outside debconf
+ # or whether the user switched dc_eximconfig_configtype
+ db_get exim4/dc_relay_nets || true
+ dc_relay_nets="$RET"
+ db_get exim4/dc_relay_domains || true
+ dc_relay_domains="$RET"
+
+ if [ "x${dc_relay_nets}" != "x" ] ; then
+ db_input medium exim4/dc_relay_nets || true
+ NEXTSTATE=$(($STATE + 1))
+ fi
+ if [ "x${dc_relay_domains}" != "x" ] ; then
+ NEXTSTATE=$(($STATELIMIT + 1))
+ db_input medium exim4/dc_relay_domains || true
+ fi
+ ;;
+ 30)
+ PREVSTATE=$(($STATE - 1))
+ NEXTSTATE=$(($STATELIMIT + 1))
+ db_input low exim4/dc_minimaldns || true
+ ;;
+
+ esac
+ if db_go; then
+ STATE=$NEXTSTATE
+ else
+ STATE=$PREVSTATE
+ fi
+done
+
+# make sure dc_local_interfaces is set to sane value
+if [ "x${dc_local_interfaces}" = "xnotset" ] ; then
+ dc_local_interfaces=''
+ db_set exim4/dc_local_interfaces ''
+fi
+
+if [ ! -e /etc/aliases ] ; then
+ db_input high exim4/dc_postmaster || true
+ db_go || true
+fi
+
+db_get exim4/dc_postmaster || true
+dc_postmaster=`echo "$RET" | stripwhitespace`
+
+if [ -e /etc/aliases ] &&
+ ! grep -q '^root:[[:space:]]*[[:alnum:]]' /etc/aliases && \
+ [ "x${dc_postmaster}" != "xnone" ]; then
+ # no alias for root and exim4/dc_postmaster != "none".
+ db_input high exim4/dc_noalias_regenerate || true
+ db_go || true
+ db_get exim4/dc_noalias_regenerate
+ dc_noalias_regenerate="$RET"
+ if [ "x${dc_noalias_regenerate}" = "xtrue" ] ; then
+ db_input high exim4/dc_postmaster || true
+ db_go || true
+ db_get exim4/dc_postmaster || true
+ dc_postmaster=`echo "$RET" | stripwhitespace`
+ fi
+fi
+
+if [ "x${dc_postmaster}" = "x" ] ; then
+ # FIXME convert empty string to "none"
+ db_set exim4/dc_postmaster "none"
+ dc_postmaster="none"
+fi
+
+# if [ "x${dc_eximconfig_configtype}" = "xsatellite" ] || [ "x${dc_eximconfig_configtype}" = "xlocal" ] ; then
+# # reset dc_relay_domains dc_relay_nets and dc_other_hostnames
+# db_set exim4/dc_relay_domains ""
+# db_set exim4/dc_relay_nets ""
+# db_set exim4/dc_other_hostnames ""
+# fi