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:
|
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=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
|
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:
|
||||||
# Run containers
|
# Run containers
|
||||||
|
|
|
@ -7,23 +7,23 @@ keysize=${1:-2048}
|
||||||
|
|
||||||
# Getting domains from mail accounts
|
# Getting domains from mail accounts
|
||||||
if [ -f /tmp/docker-mailserver/postfix-accounts.cf ]; then
|
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
|
do
|
||||||
domain=$(echo ${login} | cut -d @ -f2)
|
domain=$(echo ${login} | cut -d @ -f2)
|
||||||
echo ${domain} >> /tmp/vhost.tmp
|
echo ${domain} >> /tmp/vhost.tmp
|
||||||
done < /tmp/docker-mailserver/postfix-accounts.cf
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Getting domains from mail aliases
|
# Getting domains from mail aliases
|
||||||
if [ -f /tmp/docker-mailserver/postfix-virtual.cf ]; then
|
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
|
do
|
||||||
# Setting variables for better readability
|
# Setting variables for better readability
|
||||||
uname=$(echo ${from} | cut -d @ -f1)
|
uname=$(echo ${from} | cut -d @ -f1)
|
||||||
domain=$(echo ${from} | cut -d @ -f2)
|
domain=$(echo ${from} | cut -d @ -f2)
|
||||||
# if they are equal it means the line looks like: "user1 other@domain.tld"
|
# if they are equal it means the line looks like: "user1 other@domain.tld"
|
||||||
test "$uname" != "$domain" && echo ${domain} >> /tmp/vhost.tmp
|
test "$uname" != "$domain" && echo ${domain} >> /tmp/vhost.tmp
|
||||||
done < /tmp/docker-mailserver/postfix-virtual.cf
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Keeping unique entries
|
# Keeping unique entries
|
||||||
|
|
|
@ -10,4 +10,4 @@ errex() {
|
||||||
[ -f $DATABASE ] || errex "No postfix-virtual.cf file"
|
[ -f $DATABASE ] || errex "No postfix-virtual.cf file"
|
||||||
[ -s $DATABASE ] || errex "Empty postfix-virtual.cf - no aliases have been added"
|
[ -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
|
# Lock database even though we are only reading
|
||||||
(
|
(
|
||||||
flock -e 200
|
flock -e 200
|
||||||
awk -F '|' '{ print $1; }' $DATABASE
|
(grep -v "^\s*$\|^\s*\#" "$DATABASE" || true) | awk -F '|' '{ print $1; }'
|
||||||
) 200<$DATABASE
|
) 200<$DATABASE
|
||||||
|
|
||||||
|
|
|
@ -91,11 +91,11 @@ if [[ $chksum == *"FAIL"* ]]; then
|
||||||
fi
|
fi
|
||||||
# add domain-specific auth from config file
|
# add domain-specific auth from config file
|
||||||
if [ -f /tmp/docker-mailserver/postfix-sasl-password.cf ]; then
|
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
|
if ! echo "$line" | grep -q -e "\s*#"; then
|
||||||
echo "$line" >> /etc/postfix/sasl_passwd
|
echo "$line" >> /etc/postfix/sasl_passwd
|
||||||
fi
|
fi
|
||||||
done < /tmp/docker-mailserver/postfix-sasl-password.cf
|
done
|
||||||
fi
|
fi
|
||||||
# add default relay
|
# add default relay
|
||||||
if [ ! -z "$RELAY_USER" ] && [ ! -z "$RELAY_PASSWORD" ]; then
|
if [ ! -z "$RELAY_USER" ] && [ ! -z "$RELAY_PASSWORD" ]; then
|
||||||
|
@ -103,11 +103,11 @@ if [[ $chksum == *"FAIL"* ]]; then
|
||||||
fi
|
fi
|
||||||
# add relay maps from file
|
# add relay maps from file
|
||||||
if [ -f /tmp/docker-mailserver/postfix-relaymap.cf ]; then
|
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
|
if ! echo "$line" | grep -q -e "\s*#"; then
|
||||||
echo "$line" >> /etc/postfix/relayhost_map
|
echo "$line" >> /etc/postfix/relayhost_map
|
||||||
fi
|
fi
|
||||||
done < /tmp/docker-mailserver/postfix-relaymap.cf
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -165,14 +165,14 @@ if [[ $chksum == *"FAIL"* ]]; then
|
||||||
if [ -f /tmp/docker-mailserver/postfix-virtual.cf ]; then
|
if [ -f /tmp/docker-mailserver/postfix-virtual.cf ]; then
|
||||||
# Copying virtual file
|
# Copying virtual file
|
||||||
cp -f /tmp/docker-mailserver/postfix-virtual.cf /etc/postfix/virtual
|
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
|
do
|
||||||
# Setting variables for better readability
|
# Setting variables for better readability
|
||||||
uname=$(echo ${from} | cut -d @ -f1)
|
uname=$(echo ${from} | cut -d @ -f1)
|
||||||
domain=$(echo ${from} | cut -d @ -f2)
|
domain=$(echo ${from} | cut -d @ -f2)
|
||||||
# if they are equal it means the line looks like: "user1 other@domain.tld"
|
# if they are equal it means the line looks like: "user1 other@domain.tld"
|
||||||
test "$uname" != "$domain" && echo ${domain} >> /tmp/vhost.tmp
|
test "$uname" != "$domain" && echo ${domain} >> /tmp/vhost.tmp
|
||||||
done < /tmp/docker-mailserver/postfix-virtual.cf
|
done
|
||||||
fi
|
fi
|
||||||
if [ -f /tmp/docker-mailserver/postfix-regexp.cf ]; then
|
if [ -f /tmp/docker-mailserver/postfix-regexp.cf ]; then
|
||||||
# Copying regexp alias file
|
# 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
|
[[ $(grep ",$" /tmp/docker-mailserver/postfix-virtual.cf) ]] && sed -i -e "s/, /,/g" -e "s/,$//g" /tmp/docker-mailserver/postfix-virtual.cf
|
||||||
# Copying virtual file
|
# Copying virtual file
|
||||||
cp -f /tmp/docker-mailserver/postfix-virtual.cf /etc/postfix/virtual
|
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
|
do
|
||||||
# Setting variables for better readability
|
# Setting variables for better readability
|
||||||
uname=$(echo ${from} | cut -d @ -f1)
|
uname=$(echo ${from} | cut -d @ -f1)
|
||||||
domain=$(echo ${from} | cut -d @ -f2)
|
domain=$(echo ${from} | cut -d @ -f2)
|
||||||
# if they are equal it means the line looks like: "user1 other@domain.tld"
|
# if they are equal it means the line looks like: "user1 other@domain.tld"
|
||||||
test "$uname" != "$domain" && echo ${domain} >> /tmp/vhost.tmp
|
test "$uname" != "$domain" && echo ${domain} >> /tmp/vhost.tmp
|
||||||
done < /tmp/docker-mailserver/postfix-virtual.cf
|
done
|
||||||
else
|
else
|
||||||
notify 'inf' "Warning 'config/postfix-virtual.cf' is not provided. No mail alias/forward created."
|
notify 'inf' "Warning 'config/postfix-virtual.cf' is not provided. No mail alias/forward created."
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
submission/inet/smtpd_sasl_security_options=noanonymous
|
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
|
/^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
|
/^bounce.*@.*/ external1@otherdomain.tld
|
||||||
/^postmaster@/ user1@localhost.localdomain
|
/^postmaster@/ user1@localhost.localdomain
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
alias1@localhost.localdomain user1@localhost.localdomain
|
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
|
alias2@localhost.localdomain external1@otherdomain.tld
|
||||||
@localdomain2.com user1@localhost.localdomain
|
@localdomain2.com user1@localhost.localdomain
|
||||||
|
|
Loading…
Reference in a new issue