You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

50 lines
1.5 KiB

  1. #!/bin/bash
  2. # Update hostname if given
  3. if [ -f /mail_settings/myhostname ]; then
  4. sed -i -e "s/myhostname = localhost/myhostname = $(sed 's:/:\\/:g' /mail_settings/myhostname)/" /etc/postfix/main.cf
  5. echo $(sed 's:/:\\/:g' /mail_settings/myhostname) > /etc/mailname
  6. fi
  7. # Configure mail delivery to dovecot
  8. cp /mail_settings/aliases /etc/postfix/virtual
  9. cp /mail_settings/domains /etc/postfix/virtual-mailbox-domains
  10. # Parse mailbox settings
  11. mkdir -p /etc/postfix/tmp
  12. awk < /etc/postfix/virtual '{ print $2 }' > /etc/postfix/tmp/virtual-receivers
  13. sed -r 's,(.+)@(.+),\2/\1/,' /etc/postfix/tmp/virtual-receivers > /etc/postfix/tmp/virtual-receiver-folders
  14. paste /etc/postfix/tmp/virtual-receivers /etc/postfix/tmp/virtual-receiver-folders > /etc/postfix/virtual-mailbox-maps
  15. # Give postfix ownership of its files
  16. chown -R postfix:postfix /etc/postfix
  17. # Map virtual aliases and user/filesystem mappings
  18. postmap /etc/postfix/virtual
  19. postmap /etc/postfix/virtual-mailbox-maps
  20. chown -R postfix:postfix /etc/postfix
  21. # add global sieve script
  22. mkdir -p /vmail/sieve && cp /mail_settings/spam-global.sieve /vmail/sieve/
  23. # Make user vmail own all mail folders
  24. chown -R vmail:vmail /vmail
  25. chmod u+w /vmail
  26. # Add password file
  27. cp /mail_settings/passwords /etc/dovecot/passwd
  28. # set mynetworks
  29. sed -i \
  30. -e "s#^mynetworks = .*#mynetworks = $(cat /mail_settings/postfix-networks | tr -d '\n')#" \
  31. /etc/postfix/main.cf
  32. # Run boot scripts
  33. for SCRIPT in /boot.d/*
  34. do
  35. if [ -f "$SCRIPT" -a -x "$SCRIPT" ]; then
  36. "$SCRIPT"
  37. fi
  38. done