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

« back to all changes in this revision

Viewing changes to debian/exim4-config-simple/debian/debconf/update-exim4.conf

  • 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:
1
 
#!/bin/sh
2
 
# update-exim4.conf(8) - Generate /var/lib/exim4/config.autogenerated
3
 
 
4
 
 
5
 
# exit immediately if /etc/exim4/exim4.conf exists
6
 
[ -e /etc/exim4/exim4.conf ] && exit 0
7
 
 
8
 
EXIM="/usr/sbin/exim4"
9
 
 
10
 
UPEX4C_confdir="/etc/exim4"
11
 
UPEX4C_verbose=no
12
 
UPEX4C_comments=no
13
 
UPEX4C_autoconfigfile=/var/lib/exim4/config.autogenerated
14
 
UPEX4C_outputfile="${UPEX4C_autoconfigfile}"
15
 
 
16
 
usage() {
17
 
cat <<EOF
18
 
$0 - Generate exim4 configuration files
19
 
       Options:
20
 
       -v|--verbose - Enable verbose mode, tell about ignored files
21
 
       -h|--help - Show this message
22
 
       --keepcomments - Do not remove comment lines
23
 
       --removecomments - Remove comment lines
24
 
       -o|--output file - write output to file instead of ${UPEX4C_outputfile}
25
 
       -d|--confdir directory - read input from given directory instead of ${UPEX4C_confdir}
26
 
EOF
27
 
}
28
 
 
29
 
# also from Branden
30
 
errormessage () {
31
 
        # pretty-print messages of arbitrary length (no trailing newline)
32
 
        echo "$*" | fold -s -w ${COLUMNS:-80} >&2;
33
 
}
34
 
 
35
 
## Parse commandline
36
 
TEMP=$(getopt -n update-exim4.conf \
37
 
        -l keepcomments,removecomments,output:,confdir:,help,verbose -- \
38
 
        +o:d:vh "$@")
39
 
 
40
 
if test "$?" != 0; then
41
 
        echo "Terminating..." >&2
42
 
        exit 1
43
 
fi
44
 
 
45
 
eval set -- ${TEMP}
46
 
while test "$1" != "--"; do
47
 
        case $1 in
48
 
                -h|--help)
49
 
                        usage
50
 
                        exit 0
51
 
                ;;
52
 
                -v|--verbose)
53
 
                        UPEX4C_verbose=yes
54
 
                ;;
55
 
                --keepcomments)
56
 
                        UPEX4C_comments=yes
57
 
                ;;
58
 
                --removecomments)
59
 
                        UPEX4C_comments=no
60
 
                ;;
61
 
                -o|--output)
62
 
                        shift
63
 
                        UPEX4C_outputfile="$1"
64
 
                ;;
65
 
                -d|--confdir)
66
 
                        shift
67
 
                        UPEX4C_confdir="$1"
68
 
                ;;
69
 
        esac
70
 
        shift
71
 
done
72
 
shift
73
 
 
74
 
# No non-option arguments allowed.
75
 
if [ "$#" -ne 0 ]; then
76
 
        echo "No non option arguments ($@) allowed" >&2
77
 
        usage >&2
78
 
        exit 1
79
 
fi
80
 
 
81
 
UPEX4C_confd=$UPEX4C_confdir/conf.d
82
 
 
83
 
[ -d ${UPEX4C_confd} ] || \
84
 
{ printf "$0: Error, no ${UPEX4C_confd}, exiting.\n" 1>&2 ; exit 1 ; }
85
 
 
86
 
[ -d `dirname $UPEX4C_outputfile` ] || \
87
 
{ printf "$0: Error, missing `dirname $UPEX4C_outputfile`, exiting.\n" 1>&2 ; exit 1 ; }
88
 
 
89
 
. $UPEX4C_confdir/update-exim4.conf.conf || \
90
 
{ printf "$0: Error, no $UPEX4C_confdir/update-exim4.conf.conf, exiting.\n" 1>&2 ; exit 1 ; }
91
 
 
92
 
[ "x${CFILEMODE}" = "x" ] && CFILEMODE=644
93
 
 
94
 
mailname=`cat /etc/mailname | head -n 1`
95
 
 
96
 
# add localhost and mailname, get rid of spaces and trailing colons
97
 
local_domains="`echo ${mailname}:localhost:${dc_other_hostnames} | \
98
 
        sed -e 's�[: ]*$��' -e 's� *��'`"
99
 
        
100
 
UPEX4C_internal_tmp=`tempfile -m600 -p ex4`
101
 
 
102
 
trap "rm -f ${UPEX4C_internal_tmp}" EXIT INT TERM
103
 
 
104
 
gentmpconf() {
105
 
        touch ${UPEX4C_outputfile}.tmp
106
 
        chown root:Debian-exim ${UPEX4C_outputfile}.tmp
107
 
        [ -e ${UPEX4C_outputfile} ] && chown root:Debian-exim ${UPEX4C_outputfile}
108
 
        chmod 640 ${UPEX4C_outputfile}.tmp
109
 
        [ -e ${UPEX4C_outputfile} ] && chmod 640 ${UPEX4C_outputfile}
110
 
}
111
 
 
112
 
removecomments(){
113
 
        if [ "x${UPEX4C_comments}" = "xno" ] ; then
114
 
                grep -E -v '^[[:space:]]*#' ;
115
 
        else
116
 
                cat
117
 
        fi
118
 
}
119
 
 
120
 
. /etc/exim4/exim4.conf.defaults
121
 
 
122
 
case "${listenonpublic}" in
123
 
        false)
124
 
                listenonpublic='local_interfaces = 127.0.0.1'
125
 
        ;;
126
 
        true|*)
127
 
                listenonpublic='# if local_interfaces is unset, we listen on all interfaces'
128
 
        ;;
129
 
esac
130
 
 
131
 
cat << EOF > ${UPEX4C_outputfile}.tmp
132
 
#########
133
 
# WARNING WARNING WARNING
134
 
# WARNING WARNING WARNING
135
 
# WARNING WARNING WARNING
136
 
# WARNING WARNING WARNING
137
 
# WARNING WARNING WARNING
138
 
# this file is generated dynamically
139
 
# Any changes you make here will be lost.
140
 
# WARNING WARNING WARNING
141
 
# WARNING WARNING WARNING
142
 
# WARNING WARNING WARNING
143
 
# WARNING WARNING WARNING
144
 
# WARNING WARNING WARNING
145
 
#########
146
 
EOF
147
 
 
148
 
cat /etc/exim4/exim4.conf.source | \
149
 
removecomments | \
150
 
sed -e "s�DEBCONFlocal_domainsDEBCONF�@:${local_domains}�g" \
151
 
        -e "s�DEBCONFrelay_domainsDEBCONF�${relay_domains}�g" \
152
 
        -e "s�DEBCONFrelay_netsDEBCONF�${relay_nets}�g" \
153
 
        -e "s�DEBCONFvisiblenameDEBCONF�${mailname}�g" \
154
 
        -e "s�DEBCONFreadhostDEBCONF�${readhost}�g" \
155
 
        -e "s�DEBCONFsmarthostDEBCONF�${smarthost}�g" \
156
 
        -e "s�DEBCONFconfigtypeDEBCONF�${eximconfig_configtype}�g" \
157
 
        -e "s�DEBCONFlistenonpublicDEBCONF�${listenonpublic}�g" \
158
 
        >> ${UPEX4C_outputfile}.tmp
159
 
 
160
 
# test validity if called without -o
161
 
if [ "x${UPEX4C_outputfile}" = "x${UPEX4C_autoconfigfile}" ] ; then
162
 
        if ! ${EXIM} -C "${UPEX4C_outputfile}.tmp" -bV > /dev/null ; then
163
 
                errormessage "Invalid new configfile ${UPEX4C_outputfile}.tmp"
164
 
                errormessage "not installing ${UPEX4C_outputfile}.tmp to ${UPEX4C_outputfile}"
165
 
                exit 1
166
 
        fi
167
 
fi
168
 
 
169
 
mv -f ${UPEX4C_outputfile}.tmp ${UPEX4C_outputfile}