LDAP can now be disabled by not defining SEARCH_BASE

This commit is contained in:
Deon George 2023-05-02 17:23:33 +10:00
parent 5be914ec97
commit 47f227463c
3 changed files with 23 additions and 19 deletions

View File

@ -1,8 +1,8 @@
#relayhost = /etc/postfix/custom/relay_host #relayhost = /etc/postfix/custom/relay_host
relay_domains = lmdb:/etc/postfix/custom/relay_domains relay_domains = lmdb:/etc/postfix/custom/relay_domains
ldap:/etc/postfix/custom/ldap_relay_domains # ldap:/etc/postfix/custom/ldap_relay_domains
relay_recipient_maps = lmdb:/etc/postfix/custom/relay_recipient_maps relay_recipient_maps = lmdb:/etc/postfix/custom/relay_recipient_maps
ldap:/etc/postfix/custom/ldap_relay_recipient_maps # ldap:/etc/postfix/custom/ldap_relay_recipient_maps
transport_maps = lmdb:/etc/postfix/custom/relay_domains transport_maps = lmdb:/etc/postfix/custom/relay_domains
#transport_maps = $relay_domains #transport_maps = $relay_domains
#relay_transport = lmdb:/etc/postfix/custom/relay_domains <-- THIS DOESNT WORK? #relay_transport = lmdb:/etc/postfix/custom/relay_domains <-- THIS DOESNT WORK?

View File

@ -2,14 +2,14 @@
##virtual_alias_domains = lmdb:/etc/postfix/custom/virtual_alias_domains ##virtual_alias_domains = lmdb:/etc/postfix/custom/virtual_alias_domains
## ldap:/etc/postfix/custom/ldap_virtual_mailbox_domains ## ldap:/etc/postfix/custom/ldap_virtual_mailbox_domains
virtual_alias_maps = lmdb:/etc/postfix/custom/virtual_alias_maps virtual_alias_maps = lmdb:/etc/postfix/custom/virtual_alias_maps
ldap:/etc/postfix/custom/ldap_virtual_alias_maps # ldap:/etc/postfix/custom/ldap_virtual_alias_maps
virtual_mailbox_base = /var/mail/vhosts virtual_mailbox_base = /var/mail/vhosts
#virtual_mailbox_domains = @VIRTUAL_DOMAINS@ #virtual_mailbox_domains = @VIRTUAL_DOMAINS@
## @note virtual_mailbox_domains cannot be a map, so the below two definitions *WONT* work ## @note virtual_mailbox_domains cannot be a map, so the below two definitions *WONT* work
##virtual_mailbox_domains = lmdb:/etc/postfix/custom/virtual_mailbox_domains ##virtual_mailbox_domains = lmdb:/etc/postfix/custom/virtual_mailbox_domains
## ldap:/etc/postfix/custom/ldap_virtual_mailbox_domains ## ldap:/etc/postfix/custom/ldap_virtual_mailbox_domains
virtual_mailbox_maps = lmdb:/etc/postfix/custom/virtual_mailbox_maps virtual_mailbox_maps = lmdb:/etc/postfix/custom/virtual_mailbox_maps
ldap:/etc/postfix/custom/ldap_virtual_mailbox_maps # ldap:/etc/postfix/custom/ldap_virtual_mailbox_maps
#virtual_transport = virtual #virtual_transport = virtual
virtual_minimum_uid = 100 virtual_minimum_uid = 100
virtual_uid_maps = static:5000 virtual_uid_maps = static:5000

12
init
View File

@ -62,22 +62,26 @@ if [ -z "$@" ]; then
postmap -o lmdb:${CUSTOM}/virtual_mailbox_maps postmap -o lmdb:${CUSTOM}/virtual_mailbox_maps
# Create some default LDAP templates # Create some default LDAP templates
if [ ! -f ${CUSTOM}/ldap_virtual_alias_maps -a -n "${LDAP_SEARCH_BASE}" ]; then if [ -n "${LDAP_SEARCH_BASE}" ]; then
sed -i -e "s%^# ldap:% ldap:%" ${POSTFIX}/main.cf
if [ ! -f ${CUSTOM}/ldap_virtual_alias_maps ]; then
cp ${DEFAULTS}/ldap_virtual_alias_maps ${CUSTOM}/ cp ${DEFAULTS}/ldap_virtual_alias_maps ${CUSTOM}/
sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_virtual_alias_maps sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_virtual_alias_maps
fi fi
if [ ! -f ${CUSTOM}/ldap_virtual_mailbox_maps -a -n "${LDAP_SEARCH_BASE}" ]; then if [ ! -f ${CUSTOM}/ldap_virtual_mailbox_maps ]; then
cp ${DEFAULTS}/ldap_virtual_mailbox_maps ${CUSTOM}/ cp ${DEFAULTS}/ldap_virtual_mailbox_maps ${CUSTOM}/
sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_virtual_mailbox_maps sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_virtual_mailbox_maps
fi fi
if [ ! -f ${CUSTOM}/ldap_relay_domains -a -n "${LDAP_SEARCH_BASE}" ]; then if [ ! -f ${CUSTOM}/ldap_relay_domains ]; then
cp ${DEFAULTS}/ldap_relay_domains ${CUSTOM}/ cp ${DEFAULTS}/ldap_relay_domains ${CUSTOM}/
sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_relay_domains sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_relay_domains
fi fi
if [ ! -f ${CUSTOM}/ldap_relay_recipient_maps -a -n "${LDAP_SEARCH_BASE}" ]; then if [ ! -f ${CUSTOM}/ldap_relay_recipient_maps ]; then
cp ${DEFAULTS}/ldap_relay_recipient_maps ${CUSTOM}/ cp ${DEFAULTS}/ldap_relay_recipient_maps ${CUSTOM}/
sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_relay_recipient_maps sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_relay_recipient_maps
fi fi
fi
newaliases newaliases
postfix start postfix start