4 export exim4postinstisrunning
=true
5 .
/usr
/share
/debconf
/confmodule
7 if [ -n "$EX4DEBUG" ]; then
8 echo "now debugging $0 $@"
12 UE4CC
="/etc/exim4/update-exim4.conf.conf"
19 if [ "$code" -eq "0" ]; then
22 echo "Error getting debconf answer $1: debconf code=$code" >&2
31 # Edit this file and /etc/mailname by hand and execute update-exim4.conf
32 # yourself or use 'dpkg-reconfigure exim4-config'
34 # Please note that this is _not_ a dpkg-conffile and that automatic changes
35 # to this file might happen. The code handling this will honor your local
36 # changes, so this is usually fine, but will break local schemes that mess
37 # around with multiple versions of the file.
39 # update-exim4.conf uses this file to determine variable values to generate
40 # exim configuration macros for the configuration file.
42 # Most settings found in here do have corresponding questions in the
43 # Debconf configuration, but not all of them.
45 # This is a Debian specific file
51 # remove leading and ending whitespace, shrink multiple whitespace, separate
53 poma
="$(echo "$1" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:];][[:space:]]*/,/g')"
54 if [ "none" != "$poma" ] && [ "" != "$poma" ]; then
55 echo "root: ${poma}" >> /etc
/aliases
59 #initialize /etc/aliases
61 echo '# /etc/aliases' > /etc
/aliases.tmp
62 echo 'mailer-daemon: postmaster' >> /etc
/aliases.tmp
63 for i
in postmaster nobody hostmaster usenet news webmaster www
ftp abuse noc security
; do
65 done >> /etc
/aliases.tmp
66 mv /etc
/aliases.tmp
/etc
/aliases
69 alias stripwhitespace
="sed -e 's/^[[:blank:]]*//' -e 's/[[:blank:]]*$//'"
71 # return success if md5sum matches file
73 [ "$#" -eq 1 ] ||
return 1
74 [ -f "$1" ] ||
return 1
75 # first line, without the leading '# '.
76 checksum_current
="$(sed -n -e '1s/^# //' -e '1p;1q' "$1")"
78 # md5sum over the rest of the file.
79 # some versions of md5sum produce
80 # '68b329da9893e34099c7d8ad5cb9c940 -' others don't add the dash.
81 # '68b329da9893e34099c7d8ad5cb9c940'
82 checksum_new
="$(sed -n '2,$p' "$1" | md5sum | cut -d\ -f1)"
84 if [ "${checksum_current}" = "${checksum_new}" ] ; then
95 echo -n "internet site; mail is sent and received directly using SMTP"
98 echo -n "mail sent by smarthost; received via SMTP or fetchmail"
101 echo -n "mail sent by smarthost; no local mail"
104 echo -n "local delivery only; not on a network"
107 echo -n "no configuration at this time"
115 "internet site; mail is sent and received directly using SMTP")
118 "mail sent by smarthost; received via SMTP or fetchmail")
121 "mail sent by smarthost; no local mail")
124 "local delivery only; not on a network")
127 "no configuration at this time")
133 convert_transport_to_long
()
137 echo -n "Maildir format in home directory"
140 echo -n "mbox format in /var/mail/"
143 echo -n "locally customized"
147 convert_transport_to_short
()
150 "Maildir format in home directory")
151 echo -n "maildir_home"
153 "mbox format in /var/mail/")
162 # remove orphaned autogenerated conffile if unmodified. 4.20-2.
163 if [ "$1" = "configure" ] && \
164 dpkg
--compare-versions "$2" le-nl
"4.20-1" ; then
166 for i
in /etc
/exim
4/conf.d
/rewrite
/30_exim4-config_email-addresses \
167 /etc
/exim
4/conf.d
/rewrite
/35_exim4-config_masquerade
; do
168 if unmodified
"$i"; then
169 echo "Removing orphaned unmodified configfile $i" 1>&2
175 if [ "$1" = "configure" ] && \
176 dpkg
--compare-versions "$2" le-nl
"4.20-2" ; then
177 if unmodified
"/etc/exim4/conf.d/main/03_exim4-config_neverusers"; then
178 echo "Removing orphaned unmodified configfile /etc/exim4/conf.d/main/03_exim4-config_neverusers" 1>&2
179 rm "/etc/exim4/conf.d/main/03_exim4-config_neverusers"
183 # Disable orphaned inetd-entries from exim (v3) caused by bugs #202670
185 if [ "$1" = "configure" ] &&\
186 which update-inetd
> /dev
/null
&& which exim
> /dev
/null
&& \
187 [ -f /etc
/inetd.conf
] && \
188 grep -E -q '^smtp[[:space:]]*stream[[:space:]]*tcp[[:space:]]*nowait[[:space:]]*mail[[:space:]]*/usr/sbin/+exim exim -bs' /etc
/inetd.conf
190 update-inetd
--comment-chars \
#disabled\# \
191 --pattern '/usr/sbin/exim exim -bs' --disable smtp
194 if [ "$1" = "configure" ] &&\
195 ! getent passwd Debian-exim
> /dev
/null
; then
196 echo 'Adding system-user for exim (v4)' 1>&2
197 adduser
--system --group --quiet --home /var
/spool
/exim4 \
198 --no-create-home --disabled-login --force-badname Debian-exim
201 # fix permissions of /etc/exim4/passwd.client
202 if [ "$1" = "configure" ] ; then
203 if ! dpkg-statoverride
--list /etc
/exim
4/passwd.client
> /dev
/null
2>&1
205 dpkg-statoverride
--update --add root Debian-exim
0640 \
206 /etc
/exim
4/passwd.client
209 if dpkg
--compare-versions "$2" le
"4.30-1" ; then
210 find /etc
/exim4
-user mail \
( -type f
-or -type d \
) -print |\
213 if ! dpkg-statoverride
--list "$i" > /dev
/null
; then
214 chown Debian-exim
"$i"
217 find /etc
/exim4
-group mail \
( -type f
-or -type d \
) -print |\
220 if ! dpkg-statoverride
--list "$i" > /dev
/null
; then
221 chgrp Debian-exim
"$i"
229 # Configure Exim##############################
230 ##############################################
231 # valid config directives
232 dc_directives
="dc_eximconfig_configtype dc_other_hostnames dc_local_interfaces dc_readhost dc_relay_domains dc_minimaldns dc_relay_nets dc_smarthost CFILEMODE dc_use_split_config dc_hide_mailname dc_mailname_in_oh dc_localdelivery"
233 # Generate config-file if it does not yet exist
234 if [ ! -e $UE4CC ] ; then
236 for variable
in ${dc_directives} ; do
241 # If this is a fresh installation generate dummy files, which
242 # will be overwritten by update-exim4.conf
243 # if we add stuff later, we have to compare versions:
244 # if [ -z "$2" ] || [ "$2" = "<unknown>" ] || dpkg --compare-versions "$2" lt "4.14-0.4" ; then
245 # for file in /etc/exim4/conf.d/main/03_exim4-config_neverusers ;do
246 # if [ ! -f "$file" ] ; then
247 # echo "# d41d8cd98f00b204e9800998ecf8427e" > "$file"
253 # generate defaultfile
254 update-exim4defaults
--init
256 # source $UE4CC - needed for not
257 # debconf-managed values in there.
260 # Substitute values from debconf db
261 db_get exim
4/dc_eximconfig_configtype || true
262 dc_eximconfig_configtype
="$(convert_to_short "$RET")"
263 db_get exim
4/dc_local_interfaces || true
264 dc_local_interfaces
="$(printf '%s\n' "$RET" | stripwhitespace)"
265 db_get exim
4/dc_other_hostnames || true
266 dc_other_hostnames
="$(printf '%s\n' "$RET" | stripwhitespace)"
267 db_get exim
4/dc_readhost || true
268 dc_readhost
="$(printf '%s\n' "$RET" | stripwhitespace)"
269 db_get exim
4/dc_relay_domains || true
270 dc_relay_domains
="$(printf '%s\n' "$RET" | stripwhitespace)"
271 db_get exim
4/dc_relay_nets || true
272 dc_relay_nets
="$(printf '%s\n' "$RET" | stripwhitespace)"
273 db_get exim
4/dc_smarthost || true
274 dc_smarthost
="$(printf '%s\n' "$RET" | stripwhitespace)"
275 db_get exim
4/dc_minimaldns || true
276 dc_minimaldns
="$(printf '%s\n' "$RET" | stripwhitespace)"
277 db_get exim
4/mailname || true
278 mailname
="$(printf '%s\n' "$RET" | stripwhitespace)"
279 db_get exim
4/use_split_config || true
280 dc_use_split_config
="$(printf '%s\n' "$RET" | stripwhitespace)"
281 db_get exim
4/hide_mailname || true
282 dc_hide_mailname
="$(printf '%s\n' "$RET" | stripwhitespace)"
284 # overwrite dc_localdelivery with value stored in debconf db unless
285 # it is set to something else than maildir_home or mail_spool.
286 if [ "${dc_localdelivery}" = "" ] ||
287 [ "$(convert_transport_to_long ${dc_localdelivery})" != "locally customized" ] ; then
288 db_get exim
4/dc_localdelivery || true
289 dc_localdelivery
="$(convert_transport_to_short "$RET")"
292 if [ -r /var
/lib
/exim
4/addmailname2oh
] ; then
293 # .config added mailname to other hostnames, 2nd run of config script
294 # will have overwritten this change in debcond-db, therefore we need
295 # to store this externally, too.
296 .
/var
/lib
/exim
4/addmailname2oh
297 rm -f /var
/lib
/exim
4/addmailname2oh
299 db_fget
"exim4/dc_other_hostnames" mailname || true
300 dc_mailname_in_oh
="$RET"
302 [ "${CFILEMODE}" = "" ] && CFILEMODE
=644
304 db_get exim
4/dc_postmaster
305 dc_postmaster
="$(printf '%s\n' "$RET" | stripwhitespace)"
307 if [ ! -e /etc
/aliases
] ; then
310 if ! grep -q '^root:[[:space:]]*[[:alnum:]]' /etc
/aliases
&& \
311 [ "${dc_postmaster}" != "none" ]; then
312 addrootalias
"${dc_postmaster}"
315 ### write configuration to files #
317 for variable
in ${dc_directives} ; do
318 if ! grep -E -q "^[[:space:]]*${variable}=" $UE4CC ; then
319 echo "${variable}=''" >> $UE4CC
322 # insert new values, remove outdated ones.
324 # Use environment variables to communicate data to awk, to
325 # avoid shell (or awk or sed) string expansion which may
326 # expand escape sequences. Note that the variables named in
327 # ${dc_directives} (but not the variable names themselves) may
328 # contain escaped characters like \N.
330 export dc_directives
${dc_directives}
334 split( ENVIRON["dc_directives"], directives, "[ \t]" );
338 for ( i in directives )
340 regex = "^[ \t]*" directives[i] "=";
341 if ( ( $0 ~ regex ) && ( ! written ) )
343 # Add single quotes (\0x27) around the value.
344 print directives[i] "=\x27" ENVIRON[directives[i]] "\x27";
351 }' < ${UE4CC} > ${UE4CC}.tmp
353 mv ${UE4CC}.tmp
$UE4CC
355 echo $mailname > /etc
/mailname
356 ### configuration files written ##
359 if [ "${dc_eximconfig_configtype}" != "none" ]; then
362 # If dpkg-reconfigure was used implement the changes by restarting
364 if [ "${DEBCONF_RECONFIGURE}" = "1" ] ; then
365 if [ -x /etc
/init.d
/exim4
]; then
366 # use restart instead of reload, as changing listening
367 # interfaces cannot be done with HUP.
369 if [ -n "$EX4DEBUG" ]; then
372 cat /run
/exim
4/exim.pid
375 if [ "$dc_eximconfig_configtype" = "none" ]; then
376 # we may have broken config here, ignore errors
377 invoke-rc.d exim4 restart || true
379 # we must have working config here, honor errors
380 invoke-rc.d exim4 restart
382 if [ -n "$EX4DEBUG" ]; then
385 cat /run
/exim
4/exim.pid
388 echo >&2 "WARN: There are some exim4 processes still running after stopping exim"
397 # remove orphaned conffile if unmodified. 4.20-2.
398 if [ "$1" = "configure" ] && \
399 dpkg
--compare-versions "$2" le-nl
"4.20-1" && \
400 [ -e /etc
/exim
4/email-addresses
] && \
401 [ "$(md5sum /etc/exim4/email-addresses | cut -d\ -f1)" = "6bea09fbb18e4676012105fa5fc726c6" ]
403 echo "Removing orphaned unmodified configfile /etc/exim4/email-addresses" 1>&2
404 rm /etc
/exim
4/email-addresses