Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. name=$1
  4. email=$2
  5. username=$3
  6. password=$4
  7. mta=$5
  8. port=$6
  9. tls=$7
  10. org=$8
  11. state=$9
  12. shift 2
  13. country=$8
  14. emailservice=$9
  15.  
  16. cd /etc/postfix
  17.  
  18. # reinstall packages, to be honest: I don't know why. It was like this before i$
  19. # Will investigate if be can drop this.
  20. apt-get -y remove postfix
  21.  
  22. apt-get -y install postfix
  23. apt-get -y install expect
  24. apt-get -y install heirloom-mailx nail
  25. apt-get -y install ca-certificates
  26.  
  27. if [ -e main.cf.orig ]; then
  28. cp main.cf.orig main.cf
  29. else
  30. cp main.cf main.cf.orig
  31. fi
  32.  
  33. # Turn off history mode to allow ! in passwords
  34. set +H
  35.  
  36. # If TLS is used generate certificates and configure postfix to use them
  37. if [ "$tls" == "yes" ]; then
  38. rm -rf demoCA
  39. rm -f *.pem
  40. rm -f *.pm
  41. /usr/pluto/bin/Configure_Postfix_TLS.sh "$email" "$password" "$name" "$$
  42. echo "## TLS Settings" >> main.cf
  43. echo "smtp_tls_loglevel = 1" >> main.cf
  44. echo "smtp_enforce_tls = yes" >> main.cf
  45. echo "smtp_tls_CAfile = /etc/postfix/cacert.pem" >> main.cf
  46. echo "smtp_tls_cert_file = /etc/postfix/cert.pem" >> main.cf
  47. echo "smtp_tls_key_file = /etc/postfix/key.pem" >> main.cf
  48. echo "smtp_tls_session_cache_database = btree:/var/run/smtp_tls_session$
  49. echo "smtp_use_tls = yes" >> main.cf
  50. echo "smtpd_tls_CAfile = /etc/postfix/cacert.pem" >> main.cf
  51. echo "smtpd_tls_cert_file = /etc/postfix/cert.pem" >> main.cf
  52. echo "smtpd_tls_key_file = /etc/postfix/key.pem" >> main.cf
  53. echo "smtpd_tls_received_header = yes" >> main.cf
  54. echo "smtpd_tls_session_cache_database = btree:/var/run/smtpd_tls_sessi$
  55. echo "smtpd_use_tls = yes" >> main.cf
  56. echo "tls_random_source = dev:/dev/urandom" >> main.cf
  57. fi
  58.  
  59. # Generate new postfix config files
  60. echo "dcerouter relay:[dcerouter]" >transport
  61. echo "* smtp:[$mta]:$port" >>transport
  62. /usr/sbin/postmap transport
  63.  
  64. echo "[$mta]:$port $username:$password" >sasl_passwd
  65. chown root:root /etc/postfix/sasl_passwd && chmod 600 /etc/postfix/sasl_passwd
  66. /usr/sbin/postmap hash:/etc/postfix/sasl_passwd
  67.  
  68. rm -f generic ; touch generic
  69. /usr/sbin/postmap generic
  70.  
  71. echo "" >> main.cf
  72. echo "## SASL Settings" >> main.cf
  73. echo "# This is going in to THIS server" >> main.cf
  74. echo "smtpd_sasl_auth_enable = no" >> main.cf
  75. echo "# We need this" >> main.cf
  76. echo "smtp_sasl_auth_enable = yes" >> main.cf
  77. echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> main.cf
  78. echo "smtpd_sasl_local_domain = $myhostname" >> main.cf
  79. echo "smtp_sasl_security_options = noanonymous" >> main.cf
  80. echo "#smtp_sasl_security_options =" >> main.cf
  81. echo "smtp_sasl_tls_security_options = noanonymous" >> main.cf
  82. echo "smtpd_sasl_application_name = smtpd" >> main.cf
  83. echo "" >> main.cf
  84. echo "relayhost = [$mta]:$port" >> main.cf
  85. echo "disable_dns_lookups = yes" >> main.cf
  86. echo "smtp_generic_maps = hash:/etc/postfix/generic" >> main.cf
  87. echo "transport_maps = hash:/etc/postfix/transport" >> main.cf
  88.  
  89. #cp demoCA/cacert.pem .
  90. #chmod 644 cert.pem
  91. #chmod 644 cacert.pem
  92. #chmod 400 key.pem
  93.  
  94. if [ $emailservice = "gmail" ]
  95. then
  96. cat /etc/ssl/certs/Equifax_Secure_CA.pem >> /etc/postfix/cacert.pem
  97. fi
  98.  
  99. # reload new config
  100. service postfix reload
  101. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement