Guest User

Untitled

a guest
Jan 25th, 2018
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #!/bin/bash
  2. #########################################################
  3.  
  4. mgUSERNAME="MailGun Username"
  5. mgPASSWORD="COMPLEX PASSWORD"
  6. testEmail="user@example.com"
  7.  
  8. #########################################################
  9.  
  10. echo "Installing this agent may be dangerous, make sure this is the correct server!"
  11. echo
  12. epoch=`date +%s`
  13. name=`hostname`
  14. while true; do
  15. read -p "Enter the hostname of this server to confirm: '$name': " hn
  16. case $hn in
  17. $name* ) break;;
  18. * ) echo "Not correct, cancelled."; exit;;
  19. esac
  20. done
  21.  
  22. apt-get update
  23. apt-get upgrade
  24. apt-get install postfix mailutils sasl2-bin libsasl2-2 ca-certificates libsasl2-modules
  25. apt-get purge sendmail*
  26.  
  27. echo "`hostname`.local" > /etc/postfix/node-name
  28.  
  29. mv /etc/postfix/main.cf /etc/postfix/main.cf.$epoch.bak
  30.  
  31. cat > /etc/postfix/main.cf << EOL
  32.  
  33. smtpd_banner = Relay $name ESMTP Postfix (Ubuntu)
  34. biff = no
  35. myorigin = /etc/postfix/node-name
  36. mydestination =
  37. mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
  38. inet_interfaces = loopback-only
  39. relayhost = [smtp.mailgun.org]:587
  40. smtp_sasl_auth_enable = yes
  41. smtp_sasl_password_maps = static:$mgUSERNAME:$mgPASSWORD
  42. smtp_sasl_security_options = noanonymous
  43. smtp_tls_security_level = may
  44. smtpd_tls_security_level = may
  45. smtp_tls_note_starttls_offer = yes
  46. smtpd_tls_CApath = /etc/ssl/certs
  47.  
  48. EOL
  49.  
  50. service postfix reload
  51.  
  52. echo "Test mail from MailGun" | mail -s "Test Mail" $testEmail
  53.  
  54. echo "Install Completed."
Add Comment
Please, Sign In to add comment