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.

haraka.sh 1.0KB

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # Generate config
  3. if [ ! -f /haraka/config/smtp.ini ]; then
  4. haraka -i /haraka
  5. sed -i -e 's/;user=.*/user=haraka/g' /haraka/config/smtp.ini
  6. sed -i -e 's/;group=.*/group=haraka/g' /haraka/config/smtp.ini
  7. fi
  8. # Specify hostname
  9. echo $HOSTNAME > /haraka/config/host_list
  10. # Create tls directory if it doesn't
  11. mkdir -p /haraka/config/tls
  12. cd /haraka/config/tls
  13. if [ "${USE_LETSENCRYPT,,}" == "yes" -o "${USE_LETSENCRYPT,,}" == "true" ]; then
  14. # Get and install certificates from Let's Encrypt
  15. certbot certonly -n --agree-tos --email "$EMAIL" -d "$HOSTNAME" --standalone --preferred-challenges http
  16. ln -sf /etc/letsencrypt/live/$HOSTNAME/privkey.pem tls-key.pem
  17. ln -sf /etc/letsencrypt/live/$HOSTNAME/fullchain.pem tls-cert.pem
  18. else
  19. # Generate a self-signed certificate for the hostname provided
  20. rm -f tls-key.pem tls-cert.pem
  21. openssl req -subj "/O=Self Signed Certificate/CN=$HOSTNAME" -new -newkey rsa:4096 -days 365 -nodes -x509 -sha256 -keyout tls-key.pem -out tls-cert.pem
  22. fi
  23. cd -
  24. haraka -c /haraka