mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
support comments in .cf files
This commit is contained in:
parent
b6bc3bc073
commit
d0f7257333
2
Makefile
2
Makefile
|
@ -23,6 +23,8 @@ backup:
|
|||
generate-accounts:
|
||||
docker run --rm -e MAIL_USER=user1@localhost.localdomain -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' > test/config/postfix-accounts.cf
|
||||
docker run --rm -e MAIL_USER=user2@otherdomain.tld -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' >> test/config/postfix-accounts.cf
|
||||
echo "# this is a test comment, please don't delete me :'(" >> test/config/postfix-accounts.cf
|
||||
echo " # this is also a test comment, :O" >> test/config/postfix-accounts.cf
|
||||
|
||||
run:
|
||||
# Run containers
|
||||
|
|
|
@ -7,23 +7,23 @@ keysize=${1:-2048}
|
|||
|
||||
# Getting domains from mail accounts
|
||||
if [ -f /tmp/docker-mailserver/postfix-accounts.cf ]; then
|
||||
while IFS=$'|' read login pass
|
||||
(grep -v "^\s*$\|^\s*\#" /tmp/docker-mailserver/postfix-accounts.cf || true) | while IFS=$'|' read login pass
|
||||
do
|
||||
domain=$(echo ${login} | cut -d @ -f2)
|
||||
echo ${domain} >> /tmp/vhost.tmp
|
||||
done < /tmp/docker-mailserver/postfix-accounts.cf
|
||||
done
|
||||
fi
|
||||
|
||||
# Getting domains from mail aliases
|
||||
if [ -f /tmp/docker-mailserver/postfix-virtual.cf ]; then
|
||||
while read from to
|
||||
(grep -v "^\s*$\|^\s*\#" /tmp/docker-mailserver/postfix-virtual.cf || true) | while read from to
|
||||
do
|
||||
# Setting variables for better readability
|
||||
uname=$(echo ${from} | cut -d @ -f1)
|
||||
domain=$(echo ${from} | cut -d @ -f2)
|
||||
# if they are equal it means the line looks like: "user1 other@domain.tld"
|
||||
test "$uname" != "$domain" && echo ${domain} >> /tmp/vhost.tmp
|
||||
done < /tmp/docker-mailserver/postfix-virtual.cf
|
||||
done
|
||||
fi
|
||||
|
||||
# Keeping unique entries
|
||||
|
|
|
@ -10,4 +10,4 @@ errex() {
|
|||
[ -f $DATABASE ] || errex "No postfix-virtual.cf file"
|
||||
[ -s $DATABASE ] || errex "Empty postfix-virtual.cf - no aliases have been added"
|
||||
|
||||
cat $DATABASE
|
||||
(grep -v "^\s*$\|^\s*\#" $DATABASE || true)
|
||||
|
|
|
@ -13,6 +13,6 @@ errex() {
|
|||
# Lock database even though we are only reading
|
||||
(
|
||||
flock -e 200
|
||||
awk -F '|' '{ print $1; }' $DATABASE
|
||||
(grep -v "^\s*$\|^\s*\#" "$DATABASE" || true) | awk -F '|' '{ print $1; }'
|
||||
) 200<$DATABASE
|
||||
|
||||
|
|
|
@ -91,11 +91,11 @@ if [[ $chksum == *"FAIL"* ]]; then
|
|||
fi
|
||||
# add domain-specific auth from config file
|
||||
if [ -f /tmp/docker-mailserver/postfix-sasl-password.cf ]; then
|
||||
while read line; do
|
||||
(grep -v "^\s*$\|^\s*\#" /tmp/docker-mailserver/postfix-sasl-password.cf || true) | while read line; do
|
||||
if ! echo "$line" | grep -q -e "\s*#"; then
|
||||
echo "$line" >> /etc/postfix/sasl_passwd
|
||||
fi
|
||||
done < /tmp/docker-mailserver/postfix-sasl-password.cf
|
||||
done
|
||||
fi
|
||||
# add default relay
|
||||
if [ ! -z "$RELAY_USER" ] && [ ! -z "$RELAY_PASSWORD" ]; then
|
||||
|
@ -103,11 +103,11 @@ if [[ $chksum == *"FAIL"* ]]; then
|
|||
fi
|
||||
# add relay maps from file
|
||||
if [ -f /tmp/docker-mailserver/postfix-relaymap.cf ]; then
|
||||
while read line; do
|
||||
(grep -v "^\s*$\|^\s*\#" /tmp/docker-mailserver/postfix-relaymap.cf || true) | while read line; do
|
||||
if ! echo "$line" | grep -q -e "\s*#"; then
|
||||
echo "$line" >> /etc/postfix/relayhost_map
|
||||
fi
|
||||
done < /tmp/docker-mailserver/postfix-relaymap.cf
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -165,14 +165,14 @@ if [[ $chksum == *"FAIL"* ]]; then
|
|||
if [ -f /tmp/docker-mailserver/postfix-virtual.cf ]; then
|
||||
# Copying virtual file
|
||||
cp -f /tmp/docker-mailserver/postfix-virtual.cf /etc/postfix/virtual
|
||||
while read from to
|
||||
(grep -v "^\s*$\|^\s*\#" /tmp/docker-mailserver/postfix-virtual.cf || true) | while read from to
|
||||
do
|
||||
# Setting variables for better readability
|
||||
uname=$(echo ${from} | cut -d @ -f1)
|
||||
domain=$(echo ${from} | cut -d @ -f2)
|
||||
# if they are equal it means the line looks like: "user1 other@domain.tld"
|
||||
test "$uname" != "$domain" && echo ${domain} >> /tmp/vhost.tmp
|
||||
done < /tmp/docker-mailserver/postfix-virtual.cf
|
||||
done
|
||||
fi
|
||||
if [ -f /tmp/docker-mailserver/postfix-regexp.cf ]; then
|
||||
# Copying regexp alias file
|
||||
|
|
|
@ -940,14 +940,14 @@ function _setup_postfix_aliases() {
|
|||
[[ $(grep ",$" /tmp/docker-mailserver/postfix-virtual.cf) ]] && sed -i -e "s/, /,/g" -e "s/,$//g" /tmp/docker-mailserver/postfix-virtual.cf
|
||||
# Copying virtual file
|
||||
cp -f /tmp/docker-mailserver/postfix-virtual.cf /etc/postfix/virtual
|
||||
while read from to
|
||||
(grep -v "^\s*$\|^\s*\#" /tmp/docker-mailserver/postfix-virtual.cf || true) | while read from to
|
||||
do
|
||||
# Setting variables for better readability
|
||||
uname=$(echo ${from} | cut -d @ -f1)
|
||||
domain=$(echo ${from} | cut -d @ -f2)
|
||||
# if they are equal it means the line looks like: "user1 other@domain.tld"
|
||||
test "$uname" != "$domain" && echo ${domain} >> /tmp/vhost.tmp
|
||||
done < /tmp/docker-mailserver/postfix-virtual.cf
|
||||
done
|
||||
else
|
||||
notify 'inf' "Warning 'config/postfix-virtual.cf' is not provided. No mail alias/forward created."
|
||||
fi
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
submission/inet/smtpd_sasl_security_options=noanonymous
|
||||
# this is a test comment, please don't delete me :'(
|
||||
# this is also a test comment, :O
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/^test[0-9][0-9]*@localhost.localdomain/ user1@localhost.localdomain
|
||||
# this is a test comment, please don't delete me :'(
|
||||
# this is also a test comment, :O
|
||||
/^bounce.*@.*/ external1@otherdomain.tld
|
||||
/^postmaster@/ user1@localhost.localdomain
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
alias1@localhost.localdomain user1@localhost.localdomain
|
||||
# this is a test comment, please don't delete me :'(
|
||||
# this is also a test comment, :O
|
||||
alias2@localhost.localdomain external1@otherdomain.tld
|
||||
@localdomain2.com user1@localhost.localdomain
|
||||
|
|
Loading…
Reference in a new issue