~ubuntu-branches/ubuntu/hardy/exim4/hardy-proposed

« back to all changes in this revision

Viewing changes to debian/exim4-config.postinst

  • Committer: Bazaar Package Importer
  • Author(s): Marc Haber
  • Date: 2005-07-02 06:08:34 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050702060834-qk17pd52kb9nt3bj
Tags: 4.52-1
* new upstream version 4.51. (mh)
  * adapt 70_remove_exim-users_references
  * remove 37_gnutlsparams
  * adapt 36_pcre
  * adapt 31_eximmanpage
* fix package priorities to have them in sync with override again. (mh)
* Fix error in nb (Norwegian) translation.
  Thanks to Helge Hafting. (mh). Closes: #315775
* Standards-Version: 3.6.2, no changes needed. (mh)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
export exim4postinstisrunning=true
5
5
. /usr/share/debconf/confmodule
6
6
 
7
 
[ -n "$EX4DEBUG" ] && set -x
 
7
if [ -n "$EX4DEBUG" ]; then
 
8
  echo "now debugging $0 $@"
 
9
  set -x
 
10
fi
 
11
 
 
12
UE4CC="/etc/exim4/update-exim4.conf.conf"
8
13
 
9
14
db_version 2.0
10
15
 
20
25
}
21
26
 
22
27
write_header() {
23
 
        cat <<EOF > /etc/exim4/update-exim4.conf.conf
24
 
# /etc/exim4/update-exim4.conf.conf
 
28
        cat <<EOF > $UE4CC
 
29
# $UE4CC
25
30
#
26
31
# Edit this file and /etc/mailname by hand and execute update-exim4.conf
27
32
# yourself or use 'dpkg-reconfigure exim4-config'
 
33
#
 
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.
 
38
#
 
39
# update-exim4.conf uses this file to determine variable values to replace
 
40
# the DEBCONFsomethingDEBCONF strings in the configuration template files.
 
41
#
 
42
# Most settings found in here do have corresponding questions in the
 
43
# Debconf configuration, but not all of them.
 
44
#
 
45
# This is a Debian specific file
28
46
 
29
47
EOF
30
48
}
184
202
        # Configure Exim##############################
185
203
        ##############################################
186
204
        # valid config directives
187
 
        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"
 
205
        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"
188
206
        # Generate config-file if it does not yet exist
189
 
        if [ ! -e /etc/exim4/update-exim4.conf.conf ] ; then
 
207
        if [ ! -e $UE4CC ] ; then
190
208
                write_header
191
209
                for variable in ${dc_directives} ; do
192
210
                        echo "${variable}="
193
 
                done >> /etc/exim4/update-exim4.conf.conf
 
211
                done >> $UE4CC
194
212
        fi
195
213
 
196
214
        # If this is a fresh installation generate dummy files, which
208
226
        # generate defaultfile
209
227
        update-exim4defaults --init
210
228
 
211
 
        # source /etc/exim4/update-exim4.conf.conf - needed for not
 
229
        # source $UE4CC - needed for not
212
230
        # debconf-managed values in there.
213
 
        . /etc/exim4/update-exim4.conf.conf
 
231
        . $UE4CC
214
232
 
215
233
        # Substitute values from debconf db
216
234
        db_get exim4/dc_eximconfig_configtype || true
217
235
        dc_eximconfig_configtype=`convert_to_short "$RET"`
218
236
        db_get exim4/dc_local_interfaces || true
219
 
        dc_local_interfaces=`echo "$RET" | stripwhitespace`
 
237
        dc_local_interfaces=`printf '%s\n' "$RET" | stripwhitespace`
220
238
        db_get exim4/dc_other_hostnames || true
221
 
        dc_other_hostnames=`echo "$RET" | stripwhitespace`
 
239
        dc_other_hostnames=`printf '%s\n' "$RET" | stripwhitespace`
222
240
        db_get exim4/dc_readhost || true
223
 
        dc_readhost=`echo "$RET" | stripwhitespace`
 
241
        dc_readhost=`printf '%s\n' "$RET" | stripwhitespace`
224
242
        db_get exim4/dc_relay_domains || true
225
 
        dc_relay_domains=`echo "$RET" | stripwhitespace`
 
243
        dc_relay_domains=`printf '%s\n' "$RET" | stripwhitespace`
226
244
        db_get exim4/dc_relay_nets || true
227
 
        dc_relay_nets=`echo "$RET" | stripwhitespace`
 
245
        dc_relay_nets=`printf '%s\n' "$RET" | stripwhitespace`
228
246
        db_get exim4/dc_smarthost || true
229
 
        dc_smarthost=`echo "$RET" | stripwhitespace`
 
247
        dc_smarthost=`printf '%s\n' "$RET" | stripwhitespace`
230
248
        db_get exim4/dc_minimaldns || true
231
 
        dc_minimaldns=`echo "$RET" | stripwhitespace`
 
249
        dc_minimaldns=`printf '%s\n' "$RET" | stripwhitespace`
232
250
        db_get exim4/mailname || true
233
 
        mailname=`echo "$RET" | stripwhitespace`
 
251
        mailname=`printf '%s\n' "$RET" | stripwhitespace`
234
252
        db_get exim4/use_split_config || true
235
 
        dc_use_split_config=`echo "$RET" | stripwhitespace`
 
253
        dc_use_split_config=`printf '%s\n' "$RET" | stripwhitespace`
236
254
        db_get exim4/hide_mailname || true
237
 
        dc_hide_mailname=`echo "$RET" | stripwhitespace`
 
255
        dc_hide_mailname=`printf '%s\n' "$RET" | stripwhitespace`
 
256
        if [ -r /var/lib/exim4/addmailname2oh ] ; then
 
257
        # .config added mailname to other hostnames, 2nd run of config script
 
258
        # will have overwritten this change in debcond-db, therefore we need
 
259
        # to store this externally, too.
 
260
                . /var/lib/exim4/addmailname2oh
 
261
                rm -f /var/lib/exim4/addmailname2oh
 
262
        fi
 
263
        db_fget "exim4/dc_other_hostnames" mailname || true
 
264
        dc_mailname_in_oh="$RET"
238
265
 
239
266
        [ "x${CFILEMODE}" = "x" ] && CFILEMODE=644
240
267
 
241
268
        db_get exim4/dc_postmaster
242
 
        dc_postmaster=`echo "$RET" | stripwhitespace`
 
269
        dc_postmaster=`printf '%s\n' "$RET" | stripwhitespace`
243
270
        
244
271
        if [ ! -e /etc/aliases ] ; then
245
272
                writealiases
252
279
        ### write configuration to files #
253
280
        # add missing items
254
281
        for variable in ${dc_directives} ; do
255
 
                if ! grep -E -q "^[[:space:]]*${variable}=" /etc/exim4/update-exim4.conf.conf ; then
256
 
                        echo "${variable}=''" >> /etc/exim4/update-exim4.conf.conf
 
282
                if ! grep -E -q "^[[:space:]]*${variable}=" $UE4CC ; then
 
283
                        echo "${variable}=''" >> $UE4CC
257
284
                fi
258
285
        done
259
286
        # insert new values, remove outdated ones.
260
 
        sed -e "s�^[[:space:]]*dc_eximconfig_configtype=.*�dc_eximconfig_configtype='${dc_eximconfig_configtype}'�" \
261
 
        -e "s�^[[:space:]]*dc_local_interfaces=.*�dc_local_interfaces='${dc_local_interfaces}'�" \
262
 
        -e "s�^[[:space:]]*dc_other_hostnames=.*�dc_other_hostnames='${dc_other_hostnames}'�" \
263
 
        -e "s�^[[:space:]]*dc_readhost=.*�dc_readhost='${dc_readhost}'�" \
264
 
        -e "s�^[[:space:]]*dc_relay_domains=.*�dc_relay_domains='${dc_relay_domains}'�" \
265
 
        -e "s�^[[:space:]]*dc_relay_nets=.*�dc_relay_nets='${dc_relay_nets}'�" \
266
 
        -e "s�^[[:space:]]*dc_smarthost=.*�dc_smarthost='${dc_smarthost}'�" \
267
 
        -e "s�^[[:space:]]*dc_minimaldns=.*�dc_minimaldns='${dc_minimaldns}'�" \
268
 
        -e "s�^[[:space:]]*CFILEMODE=.*�CFILEMODE='${CFILEMODE}'�" \
269
 
        -e "s�^[[:space:]]*dc_never_users=.*��" \
270
 
        -e "s�^[[:space:]]*dc_use_split_config=.*�dc_use_split_config='${dc_use_split_config}'�" \
271
 
        -e "s�^[[:space:]]*dc_hide_mailname=.*�dc_hide_mailname='${dc_hide_mailname}'�" \
272
 
        < /etc/exim4/update-exim4.conf.conf \
273
 
        > /etc/exim4/update-exim4.conf.conf.tmp
274
 
        mv /etc/exim4/update-exim4.conf.conf.tmp /etc/exim4/update-exim4.conf.conf
 
287
 
 
288
        # Use environment variables to communicate data to awk, to
 
289
        # avoid shell (or awk or sed) string expansion which may
 
290
        # expand escape sequences.  Note that the variables named in
 
291
        # ${dc_directives} (but not the variable names themselves) may
 
292
        # contain escaped characters like \N.
 
293
 
 
294
        export dc_directives ${dc_directives}
 
295
 
 
296
        awk '
 
297
            BEGIN {
 
298
                split( ENVIRON["dc_directives"], directives, "[ \t]" );
 
299
            }
 
300
            {
 
301
                written = 0;
 
302
                for ( i in directives )
 
303
                   {
 
304
                       regex = "^[ \t]*" directives[i] "=";
 
305
                       if ( ( $0 ~ regex ) && ( ! written ) )
 
306
                           {
 
307
                               # Add single quotes (\0x27) around the value.
 
308
                               print directives[i] "=\x27" ENVIRON[directives[i]] "\x27";
 
309
                               written = 1;
 
310
                               break;
 
311
                           }
 
312
                   }
 
313
                   if ( ! written )
 
314
                       print $0;
 
315
            }' < ${UE4CC} > ${UE4CC}.tmp
 
316
 
 
317
        mv ${UE4CC}.tmp $UE4CC
275
318
 
276
319
        echo $mailname > /etc/mailname
277
320
        ### configuration files written ##
281
324
        [ "${dc_eximconfig_configtype}" != "exim3manual" ]; then
282
325
                update-exim4.conf
283
326
        fi
 
327
        # If dpkg-reconfigure was used implement the changes by restarting
 
328
        # the daemon.
 
329
        if [ "${DEBCONF_RECONFIGURE}" = "1" ] ; then
 
330
                if [ -x /etc/init.d/exim4 ] && \
 
331
                        command -v invoke-rc.d >/dev/null 2>&1; then
 
332
                        # use restart instead of reload, as changing listening
 
333
                        # interfaces cannot be done with HUP.
 
334
                        db_stop
 
335
                        invoke-rc.d exim4 restart || true
 
336
                fi
 
337
        fi
284
338
 
285
339
        ;;
286
340
esac