From 32d705d7077aefbacfe5f448c1fddd7abae4de90 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 11 Oct 2020 00:25:17 +0200 Subject: tidy: resolve redpill config paths before supported features --- postfix/postfix.sh | 116 ++++++++++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/postfix/postfix.sh b/postfix/postfix.sh index d8040ee..62d10c3 100755 --- a/postfix/postfix.sh +++ b/postfix/postfix.sh @@ -43,67 +43,12 @@ AMAVIS_MAXPROC=${AMAVIS_MAXPROC:-2} #DKIMPROXY_MAXPROC_IN=5 DKIMPROXY_MAXPROC_OUT=5 +# resolve redpill config paths realmsdir="/etc/local-$REDPILL" thisrealm=$(cat "/etc/local-$REALM/realm" || dnsdomainname | tr '[:lower:]' '[:upper:]') -confdir=/etc/postfix if ! [ -d "$realmsdir" ]; then warn "Realms directory \"$realmsdir\" does not exist." fi -#postgrey= -#if [ -x /usr/sbin/postgrey ]; then -# # FIXME: Use this somehow, and only warn below -# postgrey=1 -#else -# exit1 "ERROR: Greylisting support (Debian package postgrey) missing." -#fi -dovecot= -dovecot_lmtp= -dovecot_deliver= -if [ -x /usr/sbin/dovecot ]; then - dovecot=1 - if [ -x /usr/lib/dovecot/lmtp ]; then - dovecot_lmtp=1 - elif [ -x /usr/lib/dovecot/deliver ]; then - warn "Dovecot LMTP missing - (Debian package dovecot-lmtp)." - dovecot_deliver=1 - else - warn "Dovecot deliver missing." - fi -else - warn "Dovecot missing - (Debian package dovecot-core or dovecot)." -fi -tls_cert= -if [ -f "$TLS_CERT" ] && [ -f "$TLS_KEY" ]; then - tls_cert=1 -else - warn "No TLS - requires certificate \"$TLS_CERT\" and key \"$TLS_KEY\"." -fi -# TODO: enable only on systems with user accounts -submission=1 -# TODO: check that dovecot SASL is configured -sasl_inbound= -if [ -n "$tls_cert" ] && [ -n "$dovecot" ] && [ -n "$submission" ]; then - sasl_inbound=1 -else - warn "No inbound SASL authentication - requires TLS encryption and Dovecot." -fi -amavis= -if [ -x /usr/sbin/amavisd ] || [ -x /usr/sbin/amavisd-new ]; then - amavis=1 -else - warn "AMaViS missing (Debian package amavisd-new)." -fi -dkimproxy= -if [ -x /usr/sbin/dkimproxy.in ]; then - if [ "1" = "$amavis" ]; then - dkimproxy=1 - else - warn "No DKIM/Domainkey - requires DKIMproxy and AMaViS." - fi -else - warn "DKIMproxy missing (Debian package dkimproxy)." -fi - catfilefromownrealm() { set -e file=$1 @@ -111,7 +56,6 @@ catfilefromownrealm() { cat "$realmsdir/$thisrealm/$file" } - catallfilesfromotherrealms() { set -e file=$1 @@ -126,7 +70,6 @@ catallfilesfromotherrealms() { fi done } - catfirstfile() { set -e file=$1 @@ -190,6 +133,63 @@ getlinesfromfile() { catfirstfile "$param" | sed 's/#.*//' | tr '\n' ',' | sed -e 's/^[, ]*//;s/[, ]\+/,/g' -e 's/\^/ /g' -e "s/,\$//$replacements" } +#postgrey= +#if [ -x /usr/sbin/postgrey ]; then +# # FIXME: Use this somehow, and only warn below +# postgrey=1 +#else +# exit1 "ERROR: Greylisting support (Debian package postgrey) missing." +#fi +dovecot= +dovecot_lmtp= +dovecot_deliver= +if [ -x /usr/sbin/dovecot ]; then + dovecot=1 + if [ -x /usr/lib/dovecot/lmtp ]; then + dovecot_lmtp=1 + elif [ -x /usr/lib/dovecot/deliver ]; then + warn "Dovecot LMTP missing - (Debian package dovecot-lmtp)." + dovecot_deliver=1 + else + warn "Dovecot deliver missing." + fi +else + warn "Dovecot missing - (Debian package dovecot-core or dovecot)." +fi +tls_cert= +if [ -f "$TLS_CERT" ] && [ -f "$TLS_KEY" ]; then + tls_cert=1 +else + warn "No TLS - requires certificate \"$TLS_CERT\" and key \"$TLS_KEY\"." +fi +# TODO: enable only on systems with user accounts +submission=1 +# TODO: check that dovecot SASL is configured +sasl_inbound= +if [ -n "$tls_cert" ] && [ -n "$dovecot" ] && [ -n "$submission" ]; then + sasl_inbound=1 +else + warn "No inbound SASL authentication - requires TLS encryption and Dovecot." +fi +amavis= +if [ -x /usr/sbin/amavisd ] || [ -x /usr/sbin/amavisd-new ]; then + amavis=1 +else + warn "AMaViS missing (Debian package amavisd-new)." +fi +dkimproxy= +if [ -x /usr/sbin/dkimproxy.in ]; then + if [ "1" = "$amavis" ]; then + dkimproxy=1 + else + warn "No DKIM/Domainkey - requires DKIMproxy and AMaViS." + fi +else + warn "DKIMproxy missing (Debian package dkimproxy)." +fi + +confdir=/etc/postfix + _postconf() { postconf -c "$tempdir" "$1" "$(echo "$2" | tr '\n' ' ')" } -- cgit v1.2.3