MySQL support

This commit is contained in:
James Pattinson
2025-10-12 19:24:14 +00:00
parent b54014ac76
commit 35f710049a
10 changed files with 296 additions and 9 deletions

View File

@@ -4,16 +4,33 @@ set -e
# Generate main.cf from template with environment variables
envsubst < /etc/postfix/main.cf.template > /etc/postfix/main.cf
# Generate MySQL virtual alias config from template
envsubst < /etc/postfix/mysql_virtual_alias_maps.cf.template > /etc/postfix/mysql_virtual_alias_maps.cf
# Generate SASL password file from environment variables
envsubst < /etc/postfix/sasl_passwd.template > /etc/postfix/sasl_passwd
# Wait for MySQL to be ready
echo "Waiting for MySQL to be ready..."
for i in $(seq 1 30); do
if nc -z ${MYSQL_HOST} ${MYSQL_PORT} 2>/dev/null; then
echo "MySQL is ready!"
break
fi
echo "Waiting for MySQL... ($i/30)"
sleep 2
done
# Generate Postfix hash databases
postmap /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
# Regenerate sender_access database (in case of updates)
# Regenerate sender_access database
postmap /etc/postfix/sender_access
chmod 644 /etc/postfix/sender_access /etc/postfix/sender_access.db
# Set permissions on MySQL config
chmod 644 /etc/postfix/mysql_virtual_alias_maps.cf
# Start Postfix in foreground
exec postfix start-fg