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 [ -x /usr
/sbin
/update-inetd
] && [ ! -x /usr
/sbin
/exim
] && \
187 grep -E -q '^smtp[[:space:]]*stream[[:space:]]*tcp[[:space:]]*nowait[[:space:]]*mail[[:space:]]*/usr/sbin/+exim exim -bs' /etc
/inetd.conf
189 update-inetd
--comment-chars \
#disabled\# \
190 --pattern '/usr/sbin/exim exim -bs' --disable smtp
193 if [ "$1" = "configure" ] &&\
194 ! getent passwd Debian-exim
> /dev
/null
; then
195 echo 'Adding system-user for exim (v4)' 1>&2
196 adduser
--system --group --quiet --home /var
/spool
/exim4 \
197 --no-create-home --disabled-login --force-badname Debian-exim
200 # fix permissions of /etc/exim4/passwd.client
201 if [ "$1" = "configure" ] ; then
202 if ! dpkg-statoverride
--list /etc
/exim
4/passwd.client
> /dev
/null
2>&1
204 dpkg-statoverride
--update --add root Debian-exim
0640 \
205 /etc
/exim
4/passwd.client
208 if dpkg
--compare-versions "$2" le
"4.30-1" ; then
209 find /etc
/exim4
-user mail \
( -type f
-or -type d \
) -print |\
212 if ! dpkg-statoverride
--list "$i" > /dev
/null
; then
213 chown Debian-exim
"$i"
216 find /etc
/exim4
-group mail \
( -type f
-or -type d \
) -print |\
219 if ! dpkg-statoverride
--list "$i" > /dev
/null
; then
220 chgrp Debian-exim
"$i"
228 # Configure Exim##############################
229 ##############################################
230 # valid config directives
231 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"
232 # Generate config-file if it does not yet exist
233 if [ ! -e $UE4CC ] ; then
235 for variable
in ${dc_directives} ; do
240 # If this is a fresh installation generate dummy files, which
241 # will be overwritten by update-exim4.conf
242 # if we add stuff later, we have to compare versions:
243 # if [ -z "$2" ] || [ "$2" = "<unknown>" ] || dpkg --compare-versions "$2" lt "4.14-0.4" ; then
244 # for file in /etc/exim4/conf.d/main/03_exim4-config_neverusers ;do
245 # if [ ! -f "$file" ] ; then
246 # echo "# d41d8cd98f00b204e9800998ecf8427e" > "$file"
252 # generate defaultfile
253 update-exim4defaults
--init
255 # source $UE4CC - needed for not
256 # debconf-managed values in there.
259 # Substitute values from debconf db
260 db_get exim
4/dc_eximconfig_configtype || true
261 dc_eximconfig_configtype
="$(convert_to_short "$RET")"
262 db_get exim
4/dc_local_interfaces || true
263 dc_local_interfaces
="$(printf '%s\n' "$RET" | stripwhitespace)"
264 db_get exim
4/dc_other_hostnames || true
265 dc_other_hostnames
="$(printf '%s\n' "$RET" | stripwhitespace)"
266 db_get exim
4/dc_readhost || true
267 dc_readhost
="$(printf '%s\n' "$RET" | stripwhitespace)"
268 db_get exim
4/dc_relay_domains || true
269 dc_relay_domains
="$(printf '%s\n' "$RET" | stripwhitespace)"
270 db_get exim
4/dc_relay_nets || true
271 dc_relay_nets
="$(printf '%s\n' "$RET" | stripwhitespace)"
272 db_get exim
4/dc_smarthost || true
273 dc_smarthost
="$(printf '%s\n' "$RET" | stripwhitespace)"
274 db_get exim
4/dc_minimaldns || true
275 dc_minimaldns
="$(printf '%s\n' "$RET" | stripwhitespace)"
276 db_get exim
4/mailname || true
277 mailname
="$(printf '%s\n' "$RET" | stripwhitespace)"
278 db_get exim
4/use_split_config || true
279 dc_use_split_config
="$(printf '%s\n' "$RET" | stripwhitespace)"
280 db_get exim
4/hide_mailname || true
281 dc_hide_mailname
="$(printf '%s\n' "$RET" | stripwhitespace)"
283 # overwrite dc_localdelivery with value stored in debconf db unless
284 # it is set to something else than maildir_home or mail_spool.
285 if [ "${dc_localdelivery}" = "" ] ||
286 [ "$(convert_transport_to_long ${dc_localdelivery})" != "locally customized" ] ; then
287 db_get exim
4/dc_localdelivery || true
288 dc_localdelivery
="$(convert_transport_to_short "$RET")"
291 if [ -r /var
/lib
/exim
4/addmailname2oh
] ; then
292 # .config added mailname to other hostnames, 2nd run of config script
293 # will have overwritten this change in debcond-db, therefore we need
294 # to store this externally, too.
295 .
/var
/lib
/exim
4/addmailname2oh
296 rm -f /var
/lib
/exim
4/addmailname2oh
298 db_fget
"exim4/dc_other_hostnames" mailname || true
299 dc_mailname_in_oh
="$RET"
301 [ "${CFILEMODE}" = "" ] && CFILEMODE
=644
303 db_get exim
4/dc_postmaster
304 dc_postmaster
="$(printf '%s\n' "$RET" | stripwhitespace)"
306 if [ ! -e /etc
/aliases
] ; then
309 if ! grep -q '^root:[[:space:]]*[[:alnum:]]' /etc
/aliases
&& \
310 [ "${dc_postmaster}" != "none" ]; then
311 addrootalias
"${dc_postmaster}"
314 ### write configuration to files #
316 for variable
in ${dc_directives} ; do
317 if ! grep -E -q "^[[:space:]]*${variable}=" $UE4CC ; then
318 echo "${variable}=''" >> $UE4CC
321 # insert new values, remove outdated ones.
323 # Use environment variables to communicate data to awk, to
324 # avoid shell (or awk or sed) string expansion which may
325 # expand escape sequences. Note that the variables named in
326 # ${dc_directives} (but not the variable names themselves) may
327 # contain escaped characters like \N.
329 export dc_directives
${dc_directives}
333 split( ENVIRON["dc_directives"], directives, "[ \t]" );
337 for ( i in directives )
339 regex = "^[ \t]*" directives[i] "=";
340 if ( ( $0 ~ regex ) && ( ! written ) )
342 # Add single quotes (\0x27) around the value.
343 print directives[i] "=\x27" ENVIRON[directives[i]] "\x27";
350 }' < ${UE4CC} > ${UE4CC}.tmp
352 mv ${UE4CC}.tmp
$UE4CC
354 echo $mailname > /etc
/mailname
355 ### configuration files written ##
358 if [ "${dc_eximconfig_configtype}" != "none" ]; then
361 # If dpkg-reconfigure was used implement the changes by restarting
363 if [ "${DEBCONF_RECONFIGURE}" = "1" ] ; then
364 if [ -x /etc
/init.d
/exim4
]; then
365 # use restart instead of reload, as changing listening
366 # interfaces cannot be done with HUP.
368 if [ -n "$EX4DEBUG" ]; then
370 ls -al /var
/run
/exim
4/
371 cat /var
/run
/exim
4/exim.pid
374 if [ "$dc_eximconfig_configtype" = "none" ]; then
375 # we may have broken config here, ignore errors
376 invoke-rc.d exim4 restart || true
378 # we must have working config here, honor errors
379 invoke-rc.d exim4 restart
381 if [ -n "$EX4DEBUG" ]; then
383 ls -al /var
/run
/exim
4/
384 cat /var
/run
/exim
4/exim.pid
387 echo >&2 "WARN: There are some exim4 processes still running after stopping exim"
396 # remove orphaned conffile if unmodified. 4.20-2.
397 if [ "$1" = "configure" ] && \
398 dpkg
--compare-versions "$2" le-nl
"4.20-1" && \
399 [ -e /etc
/exim
4/email-addresses
] && \
400 [ "$(md5sum /etc/exim4/email-addresses | cut -d\ -f1)" = "6bea09fbb18e4676012105fa5fc726c6" ]
402 echo "Removing orphaned unmodified configfile /etc/exim4/email-addresses" 1>&2
403 rm /etc
/exim
4/email-addresses