start-mailserver.patch 3.1 KB
Newer Older
1
--- /usr/local/bin/start-mailserver.sh	2018-07-31 20:48:13.000000000 +0200
2
+++ /usr/local/bin/start-mailserver.sh	2018-09-03 17:30:10.650504563 +0200
3 4 5 6 7 8 9 10 11
@@ -1,5 +1,8 @@
 #!/bin/bash
 
+# Expand docker secrets
+. /env_secrets_expand.sh
+
 ##########################################################################
 # >> DEFAULT VARS
 #
zauberstuhl's avatar
zauberstuhl committed
12
@@ -698,15 +701,31 @@ function _setup_ldap() {
zauberstuhl's avatar
zauberstuhl committed
13 14 15 16 17 18 19
 	done
 
 	notify 'inf' 'Starting to override configs'
-	for f in /etc/postfix/ldap-users.cf /etc/postfix/ldap-groups.cf /etc/postfix/ldap-aliases.cf /etc/postfix/ldap-domains.cf /etc/postfix/maps/sender_login_maps.ldap
+	for f in /etc/postfix/ldap-users.cf /etc/postfix/ldap-forward.cf /etc/postfix/ldap-groups.cf /etc/postfix/ldap-aliases.cf /etc/postfix/ldap-domains.cf /etc/postfix/maps/sender_login_maps.ldap
 	do
 		[[ $f =~ ldap-user ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_USER}"
20
-		[[ $f =~ ldap-group ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_GROUP}"
zauberstuhl's avatar
zauberstuhl committed
21
+		[[ $f =~ ldap-forward ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_USER}"
22
+		[[ $f =~ ldap-groups ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_GROUP}"
zauberstuhl's avatar
zauberstuhl committed
23 24
 		[[ $f =~ ldap-aliases ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_ALIAS}"
 		[[ $f =~ ldap-domains ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_DOMAIN}"
25 26 27
 		configomat.sh "LDAP_" "${f}"
 	done
 
zauberstuhl's avatar
zauberstuhl committed
28
+	notify 'inf' "Patching /etc/postfix/ldap-groups.cf for microlist"
29 30 31
+	LDAP_RESULT_ATTRIBUTE=sn \
+	LDAP_QUERY_FILTER=$LDAP_QUERY_FILTER_GROUP \
+		configomat.sh "LDAP_" "/etc/postfix/ldap-groups.cf"
32
+
zauberstuhl's avatar
zauberstuhl committed
33 34 35 36 37 38 39 40 41
+	notify 'inf' "Configuring microlist LDAP"
+	sed -i 's/RELAY_HOST/'$RELAY_HOST'/' /etc/microlist.ini
+	sed -i 's/RELAY_PORT/'$RELAY_PORT'/' /etc/microlist.ini
+	sed -i 's/RELAY_USER/'$RELAY_USER'/' /etc/microlist.ini
+	sed -i 's#RELAY_PASSWORD#'$RELAY_PASSWORD'#' /etc/microlist.ini
+	sed -i 's/LDAP_SERVER_HOST/'$LDAP_SERVER_HOST'/' /etc/microlist.ini
+	sed -i 's/LDAP_SEARCH_BASE/'$LDAP_SEARCH_BASE'/' /etc/microlist.ini
+	sed -i 's/LDAP_BIND_DN/'$LDAP_BIND_DN'/' /etc/microlist.ini
+	sed -i 's/LDAP_BIND_PW/'$LDAP_BIND_PW'/' /etc/microlist.ini
42 43 44 45
+
 	notify 'inf' "Configuring dovecot LDAP"
 
 	declare -A _dovecot_ldap_mapping
zauberstuhl's avatar
zauberstuhl committed
46
@@ -742,7 +761,7 @@ function _setup_ldap() {
zauberstuhl's avatar
zauberstuhl committed
47 48 49 50 51 52 53 54
 		notify 'inf' "==> Warning: /etc/postfix/ldap-domains.cf not found"
 
 	[ -f /etc/postfix/ldap-aliases.cf -a -f /etc/postfix/ldap-groups.cf ] && \
-		postconf -e "virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf, ldap:/etc/postfix/ldap-groups.cf" || \
+		postconf -e "virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf, ldap:/etc/postfix/ldap-groups.cf, proxy:ldap:/etc/postfix/ldap-forward.cf" || \
 		notify 'inf' "==> Warning: /etc/postfix/ldap-aliases.cf or /etc/postfix/ldap-groups.cf not found"
 
 	return 0
zauberstuhl's avatar
zauberstuhl committed
55
@@ -894,7 +913,8 @@ function _setup_postfix_aliases() {
56 57 58 59 60
 	fi
 
 	notify 'inf' "Configuring root alias"
-	echo "root: ${POSTMASTER_ADDRESS}" > /etc/aliases
+	echo "root: ${POSTMASTER_ADDRESS}
zauberstuhl's avatar
zauberstuhl committed
61 62 63 64 65 66 67
+microlist: \"| /usr/local/bin/microlist -config /etc/microlist.ini message\"" > /etc/aliases
 	if [ -f /tmp/docker-mailserver/postfix-aliases.cf ]; then
 		cat /tmp/docker-mailserver/postfix-aliases.cf>>/etc/aliases
 	else
-- 
2.25.0