diff options
Diffstat (limited to 'debian/exim4-config.postinst')
-rw-r--r-- | debian/exim4-config.postinst | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/debian/exim4-config.postinst b/debian/exim4-config.postinst new file mode 100644 index 0000000..ccc2b72 --- /dev/null +++ b/debian/exim4-config.postinst @@ -0,0 +1,150 @@ +#!/bin/sh + +set -e +. /usr/share/debconf/confmodule + + +db_version 2.0 + +get_value() { + db_get $1 + code="$?" + if [ "$code" -eq "0" ]; then + : + else + echo "Error getting debconf answer $1: debconf code=$code" >&2 + exit $code + fi +} + +write_header() { + cat <<EOF > /etc/exim4/update-exim4.conf.conf +# /etc/exim4/update-exim4.conf.conf +# +# Edit this file and /etc/mailname by hand and execute update-exim4.conf +# yourself or use 'dpkg-reconfigure exim4-config' +# +# comments will be lost. + +EOF +} + + +writealiases() { +echo '# /etc/aliases' > /etc/aliases.tmp +echo 'mailer-daemon: postmaster' >> /etc/aliases.tmp +for i in postmaster nobody hostmaster usenet news webmaster www ftp abuse noc security ; do + echo "${i}: root" +done >> /etc/aliases.tmp +#poma=`echo "$1" | sed -e 's/^[^A-Za-z.0-9_-]*//' -e 's/[^A-Za-z.0-9_-]*$//' \ +# -e 's/ */,/g'` +# remove leading and ending whitespace, shrink multiple whitespace, separate +# entries with commas +poma=`echo "$1" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]][[:space:]]*/,/g'` +if [ "xnone" != "x$poma" ] ; then + echo "root: $poma" >> /etc/aliases.tmp +fi +mv /etc/aliases.tmp /etc/aliases +} + +alias stripwhitespace="sed -e 's/^[[:blank:]]*//' -e 's/[[:blank:]]*$//'" + + +case "$1" in + configure) + # Configure Exim############################## + ############################################## + # Generate config-file if it does yet not exist + if [ ! -e /etc/exim4/update-exim4.conf.conf ] ; then + write_header + for variable in dc_eximconfig_configtype dc_other_hostnames \ + dc_readhost dc_relay_domains \ + dc_minimaldns \ + dc_relay_nets dc_smarthost ; do + echo "${variable}=" + done >> /etc/exim4/update-exim4.conf.conf + fi + + # If this is a fresh installation generate dummy files, which + # will be overwritten by update-exim4.conf + if [ -z "$2" -o "$2" = "<unknown>" ] ; then + for file in /etc/exim4/conf.d/main/03_exim4-config_neverusers \ + /etc/exim4/conf.d/rewrite/30_exim4-config_email-addresses \ + /etc/exim4/conf.d/rewrite/35_exim4-config_masquerade ; do + if [ ! -f "$file" ] ; then + echo "# d41d8cd98f00b204e9800998ecf8427e" > "$file" + chmod 644 "$file" + fi + done + fi + # if we add stuf later, we have to compare versions: + # if [ -z "$2" -o "$2" = "<unknown>" ] || dpkg --compare-versions "$2" lt "4.14-0.4" ; then + + # generate defaultfile + update-exim4defaults --init + + # source /etc/exim4/update-exim4.conf.conf - needed for not + # debconf-managed values in there. + . /etc/exim4/update-exim4.conf.conf + + # Substitute values from debconf db + db_get exim4/dc_eximconfig_configtype || true + dc_eximconfig_configtype=`echo "$RET" | stripwhitespace` + db_get exim4/dc_local_interfaces || true + dc_local_interfaces=`echo "$RET" | stripwhitespace` + db_get exim4/dc_other_hostnames || true + dc_other_hostnames=`echo "$RET" | stripwhitespace` + db_get exim4/dc_readhost || true + dc_readhost=`echo "$RET" | stripwhitespace` + db_get exim4/dc_relay_domains || true + dc_relay_domains=`echo "$RET" | stripwhitespace` + db_get exim4/dc_relay_nets || true + dc_relay_nets=`echo "$RET" | stripwhitespace` + db_get exim4/dc_smarthost || true + dc_smarthost=`echo "$RET" | stripwhitespace` + db_get exim4/dc_minimaldns || true + dc_minimaldns=`echo "$RET" | stripwhitespace` + db_get exim4/mailname || true + mailname=`echo "$RET" | stripwhitespace` + + [ "x${CFILEMODE}" = "x" ] && CFILEMODE=644 + + ### write configuration to files # + write_header + echo "dc_eximconfig_configtype='${dc_eximconfig_configtype}'" >> /etc/exim4/update-exim4.conf.conf + echo "dc_local_interfaces='${dc_local_interfaces}'" >> /etc/exim4/update-exim4.conf.conf + echo "dc_other_hostnames='${dc_other_hostnames}'" >> /etc/exim4/update-exim4.conf.conf + echo "dc_readhost='${dc_readhost}'" >> /etc/exim4/update-exim4.conf.conf + echo "dc_relay_domains='${dc_relay_domains}'" >> /etc/exim4/update-exim4.conf.conf + echo "dc_relay_nets='${dc_relay_nets}'" >> /etc/exim4/update-exim4.conf.conf + echo "dc_smarthost='${dc_smarthost}'" >> /etc/exim4/update-exim4.conf.conf + echo "dc_minimaldns='${dc_minimaldns}'" >> /etc/exim4/update-exim4.conf.conf + echo "CFILEMODE='${CFILEMODE}'" >> /etc/exim4/update-exim4.conf.conf + + echo $mailname > /etc/mailname + ### configuration files written ## + + db_get exim4/dc_postmaster + dc_postmaster=`echo "$RET" | stripwhitespace` + + if [ ! -e /etc/aliases ] ; then + writealiases "${dc_postmaster}" + #check whether /etc/aliases has a entry for root + elif ! grep -q '^root:[[:space:]]*[[:alnum:]]' /etc/aliases && \ + [ "x${dc_postmaster}" != "xnone" ]; then + db_get exim4/dc_noalias_regenerate + dc_noalias_regenerate="$RET" + if [ "x${dc_noalias_regenerate}" = "xtrue" ] ; then + mv /etc/aliases /etc/aliases.0 + writealiases "${dc_postmaster}" + fi + fi + + if [ "${dc_eximconfig_configtype}" != "none" ] ; then + update-exim4.conf + fi + + ;; +esac + +#DEBHELPER# |