Relax chown requirements when check_owner is false
[hcoop/debian/exim4.git] / debian / exim4-config.config
1 #!/bin/sh
2 set -e
3
4 alias stripwhitespace="sed -e 's/^[[:blank:]]*//' -e 's/[[:blank:]]*$//'"
5
6 installeddebconfversion="$(dpkg -s debconf | sed -ne '/^Version/s/^Version: //p')"
7 if [ "reconfigure" != "$1" ] && \
8 dpkg --compare-versions "${installeddebconfversion}" "le" "1.4" && \
9 [ "$exim4postinstisrunning" != "true" ] ; then
10 echo "exim4-config.postinst: [WARN] Installed debconf version is broken. Aborting preconfigure." 1>&2
11 exit 0
12 fi
13
14 . /usr/share/debconf/confmodule
15
16 if [ -n "$EX4DEBUG" ]; then
17 echo "now debugging $0 $@"
18 set -x
19 fi
20
21 UE4CC="/etc/exim4/update-exim4.conf.conf"
22
23 convert_to_long ()
24 {
25 case "$1" in
26 internet)
27 echo -n "internet site; mail is sent and received directly using SMTP"
28 ;;
29 smarthost)
30 echo -n "mail sent by smarthost; received via SMTP or fetchmail"
31 ;;
32 satellite)
33 echo -n "mail sent by smarthost; no local mail"
34 ;;
35 local)
36 echo -n "local delivery only; not on a network"
37 ;;
38 none)
39 echo -n "no configuration at this time"
40 ;;
41 esac
42 }
43 convert_to_short ()
44 {
45 case "$1" in
46 "internet site; mail is sent and received directly using SMTP")
47 echo -n "internet"
48 ;;
49 "mail sent by smarthost; received via SMTP or fetchmail")
50 echo -n "smarthost"
51 ;;
52 "mail sent by smarthost; no local mail")
53 echo -n "satellite"
54 ;;
55 "local delivery only; not on a network")
56 echo -n "local"
57 ;;
58 "no configuration at this time")
59 echo -n "none"
60 ;;
61 esac
62 }
63
64 convert_transport_to_long ()
65 {
66 case "$1" in
67 maildir_home)
68 echo -n "Maildir format in home directory"
69 ;;
70 mail_spool)
71 echo -n "mbox format in /var/mail/"
72 ;;
73 *)
74 echo -n "locally customized"
75 ;;
76 esac
77 }
78 convert_transport_to_short ()
79 {
80 case "$1" in
81 "Maildir format in home directory")
82 echo -n "maildir_home"
83 ;;
84 "mbox format in /var/mail/")
85 echo -n "mail_spool"
86 ;;
87 *)
88 echo -n "custom"
89 ;;
90 esac
91 }
92
93 # store environment variables in debconf db.
94 storevar2db() {
95 dc_eximconfig_configtype="$(printf '%s\n' "${dc_eximconfig_configtype}" | stripwhitespace)"
96 dc_local_interfaces="$(printf '%s\n' "${dc_local_interfaces}" | stripwhitespace)"
97 dc_other_hostnames="$(printf '%s\n' "${dc_other_hostnames}" | stripwhitespace)"
98 dc_readhost="$(printf '%s\n' "${dc_readhost}" | stripwhitespace)"
99 dc_relay_domains="$(printf '%s\n' "${dc_relay_domains}" | stripwhitespace)"
100 dc_relay_nets="$(printf '%s\n' "${dc_relay_nets}" | stripwhitespace)"
101 dc_smarthost="$(printf '%s\n' "${dc_smarthost}" | stripwhitespace)"
102 dc_minimaldns="$(printf '%s\n' "${dc_minimaldns}" | stripwhitespace)"
103 dc_use_split_config="$(printf '%s\n' "${dc_use_split_config}" | stripwhitespace)"
104 dc_hide_mailname="$(printf '%s\n' "${dc_hide_mailname}" | stripwhitespace)"
105 # store externally changed values to debconf.db
106 db_set exim4/dc_eximconfig_configtype \
107 "$(convert_to_long ${dc_eximconfig_configtype})"
108 db_set exim4/dc_local_interfaces "${dc_local_interfaces}"
109 db_set exim4/dc_other_hostnames "${dc_other_hostnames}"
110 db_set exim4/dc_readhost "${dc_readhost}"
111 db_set exim4/dc_relay_domains "${dc_relay_domains}"
112 db_set exim4/dc_relay_nets "${dc_relay_nets}"
113 db_set exim4/dc_smarthost "${dc_smarthost}"
114 if [ "${dc_minimaldns}" != "" ]; then
115 db_set exim4/dc_minimaldns "${dc_minimaldns}"
116 fi
117 db_set exim4/use_split_config "${dc_use_split_config}"
118 db_set exim4/hide_mailname "${dc_hide_mailname}"
119 # do not store "locally customized" in debconf db, otherwise simply
120 # removing the custom dc_localdelivery from ue4cc won't work.
121 if [ "${dc_localdelivery}" != "" ] &&
122 [ "$(convert_transport_to_long ${dc_localdelivery})" != "locally customized" ] ; then
123 db_set exim4/dc_localdelivery \
124 "$(convert_transport_to_long ${dc_localdelivery})"
125 fi
126 db_fset "exim4/dc_other_hostnames" mailname "${dc_mailname_in_oh}"
127 }
128
129 # ipv6: replace double colons in colon-separated host lists with umlaut-o
130 # replace ':' with ' : ', add leading and ending whitespace.
131 # return empty string if custom delimiter was used:
132 # local_domains = <; 172.16.0.0/12; 3ffe:ffff:836f::/48
133 # e.g: 'localhost : 172.16.0.1 :3ffe::ffff::836f::::: foo.org'
134 # ===> ' localhost : 172.16.0.1 : 3ffeöffffö836föö : foo.org '
135 alias coloncolon2oe="env -u LC_ALL LC_CTYPE=C 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/$/ /'"
136
137 # try to parse exim3 configuration file - works only if it was generated
138 # with eximconfig.
139 parseexim3() {
140 dc_mailname="$(head -n 1 /etc/mailname | stripwhitespace)" || true
141
142 # get the .... entries from
143 # host_accept_relay = 127.0.0.1 : ::::1 : ......
144 # if they exist, ie. parse list, and remove "127.0.0.1", "::::1"
145 # and "localhost" from it.
146 #
147 dc_relay_nets="$(cat $1 | grep -h '^host_accept_relay[[:blank:]]*=' | sed -e 's/^host_accept_relay[[:blank:]]*=//' | coloncolon2oe | env -u LC_ALL LC_CTYPE=C 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')"
148
149 # 'local_domains = $colonhostnames', including mailname and "localhost"
150 #
151 dc_other_hostnames="$(cat $1 | grep -h '^local_domains[[:blank:]]*=' | sed -e 's/^local_domains[[:blank:]]*=//' | coloncolon2oe | env -u LC_ALL LC_CTYPE=C sed -e 's/ localhost //g' -e "s/ ${dc_mailname} //g" -e 's/[[:blank:]]*//g' -e 's/::/:/g' -e 's/^://' -e 's/:$//' -e 's/ö/::/g')"
152
153 # relay_domains = some.domain
154 dc_relay_domains="$(cat $1 | grep -h '^relay_domains = ' | sed -e 's/^relay_domains[[:blank:]]*=[[:blank:]]*//' -e 's/[[:blank:]]*$//')"
155
156 # lookuphost router exist ---> dc_eximconfig_configtype=internet
157 #
158 if cat $1 | grep -h -A2 '^lookuphost:' | \
159 grep -h -A1 '[[:blank:]]*driver = lookuphost' | \
160 grep -h -q '[[:blank:]]*transport = remote_smtp' ; then
161 dc_eximconfig_configtype=internet
162 else
163 # smart:-director exists ---> dc_eximconfig_configtype=satellite
164 #
165 # Later we need the new_address directive to find dc_readhost.
166 # ' || true' is required for "set -e"
167 dc_readhost="$(cat $1 | grep -h -A2 '^smart:' | grep -h -A1 '^[[:blank:]]*driver = smartuser' | grep -h '^[[:blank:]]*new_address' || true)"
168
169 # smarthost router exists --> dc_eximconfig_configtype is satellite or smarthost
170 #
171 # we need the route_list directive to find dc_smarthost
172 # ' || true' is required for "set -e"
173 dc_smarthost="$(< $1 grep -A3 '^smarthost:' | grep -A2 '[[:blank:]]*driver = domainlist' | grep -A1 '^[[:blank:]]*transport = remote_smtp' | grep '^[[:blank:]]*route_list = ".*"' || true)"
174
175 if [ ! -z "${dc_readhost}" ] ; then
176 dc_eximconfig_configtype=satellite
177 elif [ ! -z "${dc_smarthost}" ] ; then
178 dc_eximconfig_configtype=smarthost
179 elif ! cat "$1" | grep -h -q '^remote_smtp:'; then
180 # dc_eximconfig_configtype=local has no remote_smtp transport.
181 dc_eximconfig_configtype=local
182 else
183 # handcrafted config. We probably misparsed, reset values
184 # and exit.
185 dc_eximconfig_configtype=''
186 dc_local_interfaces='notset'
187 dc_other_hostnames=''
188 dc_readhost=''
189 dc_relay_domains=''
190 dc_relay_nets=''
191 dc_smarthost=''
192 dc_hide_mailname=''
193 return 1
194 fi
195 fi
196
197 case ${dc_eximconfig_configtype} in
198 internet|local)
199 #paranoia
200 dc_readhost=''
201 dc_smarthost=''
202 dc_hide_mailname='false'
203 ;;
204 satellite)
205 # new_address = ${local_part}@$readhost
206 dc_readhost="$(printf '%s\n' "${dc_readhost}" | sed -e 's/^.*@//' -e 's/[[:blank:]]*$//')"
207 # route_list = "* $smtphost bydns_a"
208 dc_smarthost="$(printf '%s\n' "${dc_smarthost}" | \
209 sed -e 's/^ *route_list = "\* //' -e 's/ bydns_a"//' -e 's/[[:blank:]]*$//')"
210 dc_hide_mailname='true'
211 dc_relay_domains=''
212 ;;
213 smarthost)
214 # route_list = "* $smtphost bydns_a"
215 dc_smarthost="$(printf '%s\n' "${dc_smarthost}" | \
216 sed -e 's/^ *route_list = "\* //' -e 's/ bydns_a"//' -e 's/[[:blank:]]*$//')"
217 dc_hide_mailname='false'
218 dc_relay_domains=''
219 ;;
220 esac
221 }
222
223 ##########
224 mailname2otherhostnames() {
225 # u-ex4.conf no longer includes mailname in local domains,
226 # insert it once into other_hostnames.
227 # The debconf script might run twice, we need to store the result
228 # in a file to pass it to postinst..
229 [ -d /var/lib/exim4 ] || \
230 install -d -oroot -groot -m755 /var/lib/exim4
231 dc_mailname="$(head -n 1 /etc/mailname | stripwhitespace)" || true
232 if [ -z "${dc_other_hostnames}" ] ; then
233 dc_other_hostnames="${dc_mailname}"
234 else
235 dc_other_hostnames="$(printf '%s\n' "${dc_other_hostnames}" | stripwhitespace)":${dc_mailname}
236 fi
237 printf '%s\n' dc_other_hostnames="'""${dc_other_hostnames}""'" > \
238 /var/lib/exim4/addmailname2oh
239 db_fset "exim4/dc_other_hostnames" mailname true
240 dc_mailname_in_oh="true"
241 }
242 mailname2otherhostnamesdcloop() {
243 # append mailname to other_hostnames, once. on fresh installations.
244 if [ "${dc_mailname_in_oh}" != "true" ] ;then
245 db_get exim4/mailname
246 dc_mailname="$(printf '%s\n' "$RET"| stripwhitespace)"
247 db_get "exim4/dc_other_hostnames"
248 dc_other_hostnames="$(printf '%s\n' "$RET"| stripwhitespace)"
249 if [ -z "${dc_other_hostnames}" ] ; then
250 dc_other_hostnames="${dc_mailname}"
251 else
252 dc_other_hostnames="${dc_other_hostnames}:${dc_mailname}"
253 fi
254 db_set exim4/dc_other_hostnames "${dc_other_hostnames}"
255 db_fset "exim4/dc_other_hostnames" mailname true
256 dc_mailname_in_oh="true"
257 fi
258 }
259 ##########
260
261
262 # set to dummy value, so we can differ between unset vs (seen or set outside debconf)
263 dc_local_interfaces=notset
264
265 db_settitle exim4/exim4-config-title
266 db_get exim4/dc_eximconfig_configtype
267 dc_eximconfig_configtype="$(convert_to_short "$RET")"
268 db_get exim4/use_split_config
269 dc_use_split_config="$RET"
270 # Did we append mailname to other_hostnames yet?
271 db_fget "exim4/dc_other_hostnames" mailname || true
272 dc_mailname_in_oh="$RET"
273
274 if [ -e $UE4CC ] ; then
275 . $UE4CC || true
276 # on upgrades _once_ add mailname to other_hostnames
277 if [ -n "$2" ] && [ "$1" = "configure" ] && \
278 [ "${dc_mailname_in_oh}" != "true" ] ; then
279 mailname2otherhostnames
280 fi
281 # set defaults using these values
282 storevar2db
283 else
284 # If there are no debconf answers (running first time) and we are
285 # making a cross upgrade from exim3, try to parse its config file
286 # to seed debconf db.
287 if [ "${dc_eximconfig_configtype}" = "" ] && [ -r /etc/exim/exim.conf ] ; then
288 # parse old configfile
289 #
290 # first do unfolding of lines continued with backslash, by:
291 # 1. remove comment lines
292 # 2. remove blank lines
293 # 3. remove "\<optional space><newline><optional space>"
294 exim3confunfolded="$(tempfile -p EX3)"
295 perl -e \
296 'undef $/;
297 while (<>) {
298 s/^[[:space:]]*#[^\n]*\n//mg;
299 s/^\n//mg;
300 s/\\[[:space:]]*\n[[:space:]]*//g;
301 } continue {
302 print or die "blah";
303 }' < /etc/exim/exim.conf > "$exim3confunfolded"
304 if parseexim3 "$exim3confunfolded" ; then
305 # set defaults using these values
306 storevar2db
307 fi
308 rm -f "$exim3confunfolded"
309 fi
310 fi
311
312 ## set up default values, we cannot do this in templates file because
313 ## config script is called two times before update-exim4.conf.conf exists.
314 [ "${dc_eximconfig_configtype}" = "" ] && \
315 dc_eximconfig_configtype="local" && \
316 db_set exim4/dc_eximconfig_configtype "$(convert_to_long ${dc_eximconfig_configtype})"
317
318
319 if [ -e /etc/mailname ] ; then
320 dc_mailname="$(head -n 1 /etc/mailname | stripwhitespace)" || true
321 # store values
322 db_set exim4/mailname "${dc_mailname}"
323 else
324 db_get exim4/mailname
325 dc_mailname="$RET"
326 fi
327
328 #Set default mailname
329 if [ "${dc_mailname}" = "" ] ; then
330 dc_mailname="$(hostname --fqdn 2>/dev/null)" || dc_mailname="$(hostname)" && \
331 dc_mailname="$(printf '%s\n' "${dc_mailname}" | stripwhitespace)" && \
332 db_set exim4/mailname "${dc_mailname}"
333 fi
334 fqdn="$(hostname --fqdn 2>/dev/null)" || fqdn=''
335 db_subst exim4/dc_other_hostnames fqdn "$fqdn"
336
337 # initialize env-vars from debconf_db, if they haven't been set yet either by
338 # parseexim3() or by sourcing $UE4CC
339 if [ "${dc_readhost}" = "" ] ; then
340 db_get exim4/dc_readhost
341 dc_readhost="$RET"
342 fi
343 if [ "${dc_smarthost}" = "" ] ; then
344 db_get exim4/dc_smarthost
345 dc_smarthost="$RET"
346 fi
347 # Tricky! An empty value for this option is significant, therefore both
348 # envvar and debconf-value default to "nonset" instead of "", the
349 # following line will only change then envvars value if the config-script
350 # runs the second time without existing $UE4CC or
351 # if the debconf-db has been preseeded by other means.
352 if [ "${dc_local_interfaces}" = "notset" ]; then
353 db_get exim4/dc_local_interfaces
354 dc_local_interfaces="$RET"
355 fi
356 if [ "${dc_minimaldns}" = "" ] ; then
357 db_get exim4/dc_minimaldns
358 dc_minimaldns="$RET"
359 fi
360
361 if [ "${dc_use_split_config}" = "" ] ; then
362 if [ "${2}" = "" ] ; then
363 # fresh installation
364 db_set exim4/use_split_config false
365 dc_use_split_config="false"
366 else
367 db_set exim4/use_split_config true
368 dc_use_split_config="true"
369 fi
370 fi
371
372 if [ "${dc_localdelivery}" = "" ] ; then
373 db_get exim4/dc_localdelivery
374 dc_localdelivery="$(convert_transport_to_short "$RET")"
375 elif [ "$(convert_transport_to_long ${dc_localdelivery})" = "locally customized" ] ; then
376 dc_localdelivery="custom"
377 fi
378
379 db_version 2.0
380
381 db_capb backup
382 # initial state
383 STATE=1
384 # state to continue for all values
385 CONTSTATE=50
386 # last valid state
387 STATELIMIT=51
388 EX4QUESTION=""
389 while [ "$STATE" != 0 ] && [ "$STATE" -le "$STATELIMIT" ]; do
390 case "$STATE" in
391 1)
392 # this is now empty
393 EX4QUESTION=""
394 BACKSTATE=$(($STATE - 1))
395 FORWSTATE=$(($STATE + 1))
396 ;;
397
398 2)
399 EX4QUESTION="exim4/dc_eximconfig_configtype"
400 BACKSTATE=$(($STATE - 1))
401 FORWSTATE=$(($STATE + 1))
402 CONFIGTYPEQUESTION=2
403 db_input medium "$EX4QUESTION" || true
404 ;;
405 3)
406 EX4QUESTION=""
407 db_get exim4/dc_eximconfig_configtype
408 dc_eximconfig_configtype="$(convert_to_short "$RET")"
409 BACKSTATE=$(($STATE - 1))
410 case "${dc_eximconfig_configtype}" in
411 none)
412 # dont ask more questions
413 #FORWSTATE=$(($STATELIMIT + 1))
414 FORWSTATE=4
415 ;;
416 internet)
417 FORWSTATE=8
418 ;;
419 smarthost)
420 FORWSTATE=20
421 ;;
422 satellite)
423 FORWSTATE=30
424 ;;
425 local)
426 FORWSTATE=40
427 ;;
428 *)
429 # Should not happen. Break loop
430 FORWSTATE=$(($STATELIMIT + 1))
431 ;;
432 esac
433 ;;
434
435 4)
436 # show additional info for type=none
437 EX4QUESTION="exim4/no_config"
438 BACKSTATE=$CONFIGTYPEQUESTION
439 FORWSTATE=$(($STATE + 1))
440 # same priority as configtype because of danger of loop?
441 db_input medium "$EX4QUESTION" || true
442 ;;
443 5)
444 EX4QUESTION=""
445 BACKSTATE=$CONFIGTYPEQUESTION
446 db_get exim4/no_config || true
447 if [ "$RET" = "false" ]; then
448 FORWSTATE=$CONFIGTYPEQUESTION
449 else
450 #break loop
451 FORWSTATE=$CONTSTATE
452 fi
453 ;;
454
455 8)
456 # internet site
457 EX4QUESTION="exim4/mailname"
458 db_input medium "$EX4QUESTION" || true
459 BACKSTATE=$CONFIGTYPEQUESTION
460 FORWSTATE=$(($STATE + 1))
461 ;;
462 9)
463 EX4QUESTION="exim4/dc_local_interfaces"
464 BACKSTATE=$(($STATE - 1))
465 FORWSTATE=$(($STATE + 1))
466 if [ "${dc_local_interfaces}" = "notset" ] ; then
467 dc_local_interfaces=''
468 db_set exim4/dc_local_interfaces ''
469 fi
470 db_input medium "$EX4QUESTION" || true
471 ;;
472 10)
473 EX4QUESTION="exim4/dc_other_hostnames"
474 BACKSTATE=$(($STATE - 1))
475 FORWSTATE=$(($STATE + 1))
476 mailname2otherhostnamesdcloop
477 db_input medium "$EX4QUESTION" || true
478 ;;
479 11)
480 EX4QUESTION="exim4/dc_relay_domains"
481 db_input medium "$EX4QUESTION" || true
482 BACKSTATE=$(($STATE - 1))
483 FORWSTATE=$(($STATE + 1))
484 ;;
485 12)
486 EX4QUESTION="exim4/dc_relay_nets"
487 db_input medium "$EX4QUESTION" || true
488 BACKSTATE=$(($STATE - 1))
489 FORWSTATE=$(($STATE + 1))
490 ;;
491 13)
492 EX4QUESTION="exim4/dc_minimaldns"
493 BACKSTATE=$(($STATE - 1))
494 FORWSTATE=$(($STATE + 1))
495 db_input low "$EX4QUESTION" || true
496 ;;
497 14)
498 EX4QUESTION="exim4/dc_localdelivery"
499 BACKSTATE=$(($STATE - 1))
500 FORWSTATE=$CONTSTATE
501 # do not ask question if user has set a different transport
502 # than maildir or mailspool
503 if [ "${dc_localdelivery}" != "custom" ] ; then
504 db_input low "$EX4QUESTION" || true
505 fi
506 ;;
507
508
509 20)
510 # internet site with smarthost
511 EX4QUESTION="exim4/mailname"
512 db_input medium "$EX4QUESTION" || true
513 BACKSTATE=$CONFIGTYPEQUESTION
514 FORWSTATE=$(($STATE + 1))
515 ;;
516 21)
517 EX4QUESTION="exim4/dc_local_interfaces"
518 BACKSTATE=$(($STATE - 1))
519 FORWSTATE=$(($STATE + 1))
520 if [ "${dc_local_interfaces}" = "notset" ] ; then
521 dc_local_interfaces='127.0.0.1 ; ::1'
522 db_set exim4/dc_local_interfaces '127.0.0.1 ; ::1'
523 fi
524 db_input medium "$EX4QUESTION" || true
525 ;;
526 22)
527 EX4QUESTION="exim4/dc_other_hostnames"
528 BACKSTATE=$(($STATE - 1))
529 FORWSTATE=$(($STATE + 1))
530 mailname2otherhostnamesdcloop
531 db_input medium "$EX4QUESTION" || true
532 ;;
533 23)
534 EX4QUESTION="exim4/dc_relay_domains"
535 BACKSTATE=$(($STATE - 1))
536 FORWSTATE=$(($STATE + 1))
537 db_get "$EX4QUESTION" || true
538 dc_relay_domains="$RET"
539 # Only ask for relay domains if non-empty, since this only
540 # really works for internet site hosts. (See comment near
541 # smarthost router definition in configuration file.)
542 if [ "${dc_relay_domains}" != "" ] ; then
543 db_input medium "$EX4QUESTION" || true
544 fi
545 ;;
546 24)
547 EX4QUESTION="exim4/dc_relay_nets"
548 db_input medium "$EX4QUESTION" || true
549 BACKSTATE=$(($STATE - 1))
550 FORWSTATE=$(($STATE + 1))
551 ;;
552 25)
553 EX4QUESTION="exim4/dc_smarthost"
554 if [ "${dc_smarthost}" = "" ] ; then
555 # default to mail.mailname
556 dc_smarthost="mail.${dc_mailname}"
557 db_set exim4/dc_smarthost "${dc_smarthost}"
558 fi
559 db_input medium "$EX4QUESTION" || true
560 BACKSTATE=$(($STATE - 1))
561 FORWSTATE=$(($STATE + 1))
562 ;;
563 26)
564 EX4QUESTION="exim4/hide_mailname"
565 BACKSTATE=$(($STATE - 1))
566 FORWSTATE=$(($STATE + 1))
567 db_get exim4/mailname || true
568 dc_mailname="$RET"
569 db_get exim4/dc_other_hostnames || true
570 dc_other_hostnames="$RET"
571 db_subst exim4/hide_mailname mailname ${dc_mailname}
572 db_subst exim4/hide_mailname dc_other_hostnames \
573 ${dc_other_hostnames}
574 db_get $EX4QUESTION || true
575 dc_hide_mailname="$RET"
576 if [ "${dc_hide_mailname}" = "" ] ; then
577 dc_hide_mailname='false'
578 db_set exim4/hide_mailname "${dc_hide_mailname}"
579 fi
580 db_input medium "$EX4QUESTION" || true
581 ;;
582 27)
583 EX4QUESTION="exim4/dc_readhost"
584 BACKSTATE=$(($STATE - 1))
585 FORWSTATE=$(($STATE + 1))
586 db_get exim4/hide_mailname
587 dc_hide_mailname="$RET"
588 if [ "${dc_hide_mailname}" = "true" ];then
589 if [ "${dc_readhost}" = "" ] ; then
590 # default to mailname
591 dc_readhost="${dc_mailname}"
592 db_set exim4/dc_readhost "${dc_readhost}"
593 fi
594 db_input medium "$EX4QUESTION" || true
595 else
596 EX4QUESTION=""
597 fi
598 ;;
599 28)
600 EX4QUESTION="exim4/dc_minimaldns"
601 BACKSTATE=$(($STATE - 1))
602 FORWSTATE=$(($STATE + 1))
603 db_input low "$EX4QUESTION" || true
604 ;;
605 29)
606 EX4QUESTION="exim4/dc_localdelivery"
607 BACKSTATE=$(($STATE - 1))
608 FORWSTATE=$CONTSTATE
609 # do not ask question if user has set a different transport
610 # than maildir or mailspool
611 if [ "${dc_localdelivery}" != "custom" ] ; then
612 db_input low "$EX4QUESTION" || true
613 fi
614 ;;
615
616 30)
617 # satellite
618 EX4QUESTION="exim4/mailname"
619 db_input medium "$EX4QUESTION" || true
620 BACKSTATE=$CONFIGTYPEQUESTION
621 FORWSTATE=$(($STATE + 1))
622 ;;
623 31)
624 EX4QUESTION="exim4/dc_local_interfaces"
625 BACKSTATE=$(($STATE - 1))
626 FORWSTATE=$(($STATE + 1))
627 if [ "${dc_local_interfaces}" = "notset" ] ; then
628 dc_local_interfaces='127.0.0.1 ; ::1'
629 db_set exim4/dc_local_interfaces '127.0.0.1 ; ::1'
630 fi
631 db_input medium "$EX4QUESTION" || true
632 ;;
633 32)
634 EX4QUESTION="exim4/dc_other_hostnames"
635 BACKSTATE=$(($STATE - 1))
636 FORWSTATE=$(($STATE + 1))
637 mailname2otherhostnamesdcloop
638 db_input medium "$EX4QUESTION" || true
639 ;;
640 33)
641 EX4QUESTION="exim4/dc_readhost"
642 BACKSTATE=$(($STATE - 1))
643 FORWSTATE=$(($STATE + 1))
644 # satellite requires a mail-hub, no use asking whether there
645 # is one.
646 db_set exim4/hide_mailname "true"
647 dc_hide_mailname="true"
648 if [ "${dc_readhost}" = "" ] ; then
649 # default to domain of mailname
650 dc_readhost="${dc_mailname}"
651 db_set exim4/dc_readhost "${dc_readhost}"
652 fi
653 db_input medium "$EX4QUESTION" || true
654 ;;
655 34)
656 EX4QUESTION="exim4/dc_smarthost"
657 BACKSTATE=$(($STATE - 1))
658 FORWSTATE=$(($STATE + 1))
659 db_get exim4/dc_readhost
660 dc_readhost="$RET"
661 if [ "${dc_smarthost}" = "" ] ; then
662 # default to read_host
663 dc_smarthost="${dc_readhost}"
664 db_set exim4/dc_smarthost "${dc_smarthost}"
665 fi
666 db_input medium "$EX4QUESTION" || true
667 ;;
668 35)
669 EX4QUESTION="exim4/dc_relay_domains"
670 BACKSTATE=$(($STATE - 1))
671 FORWSTATE=$(($STATE + 1))
672 db_get "$EX4QUESTION" || true
673 dc_relay_domains="$RET"
674 # Only ask for relay domains if non-empty, since this only
675 # really works for internet site hosts. (See comment near
676 # smarthost router definition in configuration file.)
677 if [ "${dc_relay_domains}" != "" ] ; then
678 db_input medium "$EX4QUESTION" || true
679 fi
680 ;;
681 36)
682 EX4QUESTION=""
683 BACKSTATE=$(($STATE - 1))
684 FORWSTATE=$(($STATE + 1))
685 # satellite-system! Only ask for relay_nets if they are
686 # nonempty - we cannot distinguish whether they were set outside debconf
687 # or whether the user switched dc_eximconfig_configtype
688 db_get exim4/dc_relay_nets || true
689 dc_relay_nets="$RET"
690 if [ "${dc_relay_nets}" != "" ] ; then
691 db_input medium exim4/dc_relay_nets || true
692 FORWSTATE=$(($STATE + 1))
693 fi
694 ;;
695 37)
696 EX4QUESTION="exim4/dc_minimaldns"
697 BACKSTATE=$(($STATE - 1))
698 FORWSTATE=$(($STATE + 1))
699 db_input low "$EX4QUESTION" || true
700 ;;
701 38)
702 EX4QUESTION="exim4/dc_localdelivery"
703 BACKSTATE=$(($STATE - 1))
704 FORWSTATE=$CONTSTATE
705 # Only ask question if it is set to a value that is both supported
706 # by debconf (maildir_home and mail_spool) and is not set to the
707 # default value (maildir_home) since this is only used for
708 # real-*.
709 if [ "${dc_localdelivery}" = "maildir_home" ] ; then
710 db_input low "$EX4QUESTION" || true
711 fi
712 ;;
713
714 40)
715 # local mail only
716 EX4QUESTION="exim4/mailname"
717 db_input medium "$EX4QUESTION" || true
718 BACKSTATE=$CONFIGTYPEQUESTION
719 FORWSTATE=$(($STATE + 1))
720 ;;
721 41)
722 EX4QUESTION=""
723 BACKSTATE=$(($STATE - 1))
724 FORWSTATE=$(($STATE + 1))
725 if [ "${dc_local_interfaces}" = "notset" ] ; then
726 dc_local_interfaces='127.0.0.1 ; ::1'
727 db_set exim4/dc_local_interfaces '127.0.0.1 ; ::1'
728 fi
729 db_input medium exim4/dc_local_interfaces || true
730 ;;
731
732 42)
733 EX4QUESTION="exim4/dc_other_hostnames"
734 BACKSTATE=$(($STATE - 1))
735 FORWSTATE=$(($STATE + 1))
736 mailname2otherhostnamesdcloop
737 db_input medium "$EX4QUESTION" || true
738 ;;
739
740 43)
741 EX4QUESTION=""
742 BACKSTATE=$(($STATE - 1))
743 FORWSTATE=$(($STATE + 1))
744 # local mail only -system! Only ask for relay_nets/relay_domains if they are
745 # nonempty - we cannot distinguish whether they were set outside debconf
746 # or whether the user switched dc_eximconfig_configtype
747 db_get exim4/dc_relay_nets || true
748 dc_relay_nets="$RET"
749 db_get exim4/dc_relay_domains || true
750 dc_relay_domains="$RET"
751
752 if [ "${dc_relay_nets}" != "" ] ; then
753 db_input medium exim4/dc_relay_nets || true
754 fi
755 if [ "${dc_relay_domains}" != "" ] ; then
756 db_input medium exim4/dc_relay_domains || true
757 fi
758 ;;
759 44)
760 EX4QUESTION="exim4/dc_minimaldns"
761 BACKSTATE=$(($STATE - 1))
762 FORWSTATE=$(($STATE + 1))
763 db_input low "$EX4QUESTION" || true
764 ;;
765 45)
766 EX4QUESTION="exim4/dc_localdelivery"
767 BACKSTATE=$(($STATE - 1))
768 FORWSTATE=$CONTSTATE
769 # do not ask question if user has set a different transport
770 # than maildir or mailspool
771 if [ "${dc_localdelivery}" != "custom" ] ; then
772 db_input low "$EX4QUESTION" || true
773 fi
774 ;;
775 50)
776 EX4QUESTION="exim4/use_split_config"
777 BACKSTATE=$PREVSTATE
778 FORWSTATE=$(($STATELIMIT + 1))
779 db_input medium "$EX4QUESTION" || true
780 ;;
781 esac
782 PREVSTATE=$STATE
783 if db_go; then
784 STATE=$FORWSTATE
785 else
786 STATE=$BACKSTATE
787 fi
788 done
789 if [ "$STATE" = 0 ] ; then
790 # User pressed back on the first question, go back to previous
791 # package if run by base-config 2.0. #222773.
792 exit 30
793 fi
794
795 # make sure dc_local_interfaces is set to sane value
796 if [ "${dc_local_interfaces}" = "notset" ] ; then
797 dc_local_interfaces=''
798 db_set exim4/dc_local_interfaces ''
799 fi
800
801 if [ ! -e /etc/aliases ] || \
802 ! grep -q '^root:[[:space:]]*[[:alnum:]]' /etc/aliases ; then
803 db_get exim4/dc_postmaster
804 if [ -z "$RET" ] && db_get passwd/username; then
805 db_set exim4/dc_postmaster "${RET}"
806 fi
807 db_input medium exim4/dc_postmaster || true
808 db_go || true
809 fi
810
811 db_get exim4/dc_postmaster || true
812 dc_postmaster="$(printf '%s\n' "$RET" | stripwhitespace)"
813
814 # this has been commented out for a long time, remove by the end of 2007
815 # if [ "${dc_eximconfig_configtype}" = "satellite" ] || [ "${dc_eximconfig_configtype}" = "local" ] ; then
816 # # reset dc_relay_domains dc_relay_nets and dc_other_hostnames
817 # db_set exim4/dc_relay_domains ""
818 # db_set exim4/dc_relay_nets ""
819 # db_set exim4/dc_other_hostnames ""
820 # fi