update_postfix() {
# set up master.cf
- if [ -f /etc/postfix/master.cf ] && \
- ! grep -q smtp-amavis /etc/postfix/master.cf; then
- cp-update $PKG /etc/postfix/master.cf <<-EOF
- smtp-amavis unix - - n - 2 smtp
- -o smtp_data_done_timeout=1200
- -o disable_dns_lookups=yes
- -o smtp_line_length_limit=0
- -o notify_classes=protocol,resource,software
- -o max_use=10
-
- 127.0.0.1:10025 inet n - n - - smtpd
- -o content_filter=
- -o local_recipient_maps=
- -o smtpd_helo_restrictions=
- -o smtpd_client_restrictions=
- -o smtpd_sender_restrictions=
- -o smtpd_recipient_restrictions=permit_mynetworks,reject
- -o mynetworks=127.0.0.0/8
- -o strict_rfc821_envelopes=yes
- EOF
+ if [ -f /etc/postfix/master.cf ]; then
+ if ( ! grep -q smtp-amavis /etc/postfix/master.cf || \
+ dpkg --compare-versions "$2" lt $MASTTMPLVERSION ); then
+ noisy_backup /etc/postfix/master.cf
+ cp-update $PKG /etc/postfix/master.cf < $MASTTMPL
+ restart_mta=1
+ fi
+ else
+ echo "CN: Missing Postfix master.cf, please configure Postfix and restart installation."
+ exit 1
fi
- # main.cf
- postconf -e content_filter="smtp-amavis:[127.0.0.1]:10024"
-}
-
-conf_postfixize() {
- local tmp
- tmp=`basename $ACONF.dpkg-tmp.$$`
- noisy_backup $ACONF
- # detect non-postfix config
- # XXX add $inet_socket_port & $inet_socket_bind
- if egrep -q '^[[:blank:]]*\$notify_method = .*argv=/usr/sbin/sendmail -Ac.*-odd' $ACONF || \
- ! ( egrep -q '^\$forward_method = '\''smtp:127.0.0.1:10025'\'';[[:blank:]]*(#|$)' $ACONF && \
- egrep -q '^\$notify_method = \$forward_method;[[:blank:]]*(#|$)' $ACONF && \
- egrep -q '^\$inet_socket_port.*10024' $ACONF && \
- egrep -q '^\$inet_socket_bind' $ACONF ); then
- if catpatch $ACONF | patch -sfp0 --dry-run >&- 2>&-; then
- oldpwd=`pwd`
- cd `dirname $ACONF`
- cp -p $ACONF $tmp
- catpatch $tmp | patch -fp0
- cp_mv $tmp $ACONF
- cd $oldpwd
- cp_echo -mailonly "CN: $ACONF patched for postfix."
- # then try to update exact options without disturbing anything else
- elif commented_in_paragraph '^[[:blank:]]*#.*POSTFIX' \
- '^$forward_method = '\''smtp:127.0.0.1:10025'\'';[[:blank:]]*(#|$)' \
- '^\$notify_method = \$forward_method;[[:blank:]]*(#|$)' \
- -f $ACONF &&
- uncommented_in_paragraph '^[[:blank:]]*#.*MILTER' \
- '$forward_method = undef;[[:blank:]]*(#|$)' \
- '$notify_method = .*argv=/usr/sbin/sendmail -Ac.*-odd' \
- -f $ACONF; then
- cp $ACONF $tmp
- uncomment_in_paragraph '^[[:blank:]]*#.*POSTFIX' \
- '^$forward_method = '\''smtp:127.0.0.1:10025'\'';[[:blank:]]*(#|$)' \
- '^\$notify_method = \$forward_method;[[:blank:]]*(#|$)' \
- -f $tmp
- comment_in_paragraph '^[[:blank:]]*#.*MILTER' \
- '$forward_method = undef;[[:blank:]]*(#|$)' \
- '$notify_method = .*argv=/usr/sbin/sendmail -Ac.*-odd' \
- -f $tmp
- cp_mv $tmp $ACONF
- cp_echo "CN: $ACONF updated for ${mta}."
- # or just use the template
- else
- conf_from_template
- cp_echo "CN: Config generated from ${ACONFTMPL}."
+ # set up main.cf
+ if [ -f /etc/postfix/main.cf ]; then
+ if ! grep -q "^content_filter[\t ]*=[\t ]*smtp-amavis:\[127.0.0.1\]:10024[\t ]*" \
+ /etc/postfix/main.cf; then
+ postconf -e content_filter="smtp-amavis:[127.0.0.1]:10024"
+ restart_mta=1
fi
- restart_daemon=1
- changed_config=1
+ else
+ echo "CN: Missing Postfix main.cf, please configure Postfix and restart installation."
+ exit 1
fi
- restart_mta=1
}