From c3d5cbb383a9039c44d467b9b50e4097c2d19e96 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 22 Aug 2014 16:16:45 +0530 Subject: [PATCH] Added Certificate for Dovecot and Postfix --- .../stack/install/mail/ee_mod_setup_dovecot.sh | 18 ++++++++++++++++++ .../stack/install/mail/ee_mod_setup_postfix.sh | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index ca77fc4a..43b4e9e7 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -2,6 +2,14 @@ function ee_mod_setup_dovecot() { + + EE_EMAIL=$($EE_CONFIG_GET wordpress.email) + if [[ $EE_EMAIL = "" ]]; then + EE_EMAIL=$(git config user.email) + fi + + EE_HOSTNAME=$(hostname -f) + ee_lib_echo "Setting up Dovecot, please wait..." # Adding mail user with GID 5000 and UID 5000 groupadd -g 5000 vmail && useradd -g vmail -u 5000 vmail -d /var/vmail -m \ @@ -39,4 +47,14 @@ function ee_mod_setup_dovecot() # Change Dovecot log location sed -i "s/#log_path = syslog/log_path = \/var\/log\/dovecot.log/" /etc/dovecot/conf.d/10-logging.conf \ || ee_lib_error "Unable to setup Dovecot log_path, exit status = " $? + + # Configure self signed SSL for Dovecot + ee_lib_echo "Generating self signed certificate for Dovecot, please wait..." + openssl req -new -x509 -days 3650 -nodes -subj /commonName=${EE_HOSTNAME}/emailAddress=${EE_EMAIL} -out /etc/ssl/certs/dovecot.pem -keyout /etc/ssl/private/dovecot.pem &>> $EE_COMMAND_LOG + + # Setting up certificate in file + sed -i "s'/etc/dovecot/dovecot.pem'/etc/ssl/certs/dovecot.pem'" /etc/dovecot/conf.d/10-ssl.conf \ + sed -i "s'/etc/dovecot/private/dovecot.pem'/etc/ssl/private/dovecot.pem'" /etc/dovecot/conf.d/10-ssl.conf \ + || ee_lib_error "Unable to setup Dovecot SSL certificate path, exit status = " $? + } diff --git a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh index a8d19fa5..9c0bd7bb 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh @@ -2,6 +2,13 @@ function ee_mod_setup_postfix() { + + EE_EMAIL=$($EE_CONFIG_GET wordpress.email) + if [[ $EE_EMAIL = "" ]]; then + EE_EMAIL=$(git config user.email) + fi + + EE_HOSTNAME=$(hostname -f) ee_lib_echo "Setting up Postfix, please wait..." #Configure Master.cf sed -i 's/#submission/submission/' /etc/postfix/master.cf && @@ -43,4 +50,10 @@ function ee_mod_setup_postfix() cp -av /usr/share/easyengine/mail/virtual_mailbox_maps.cf /etc/postfix/mysql/virtual_mailbox_maps.cf &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to copy Postfix MySQL configuration files, exit status = " $? + # Configure self signed SSL for Postfix + ee_lib_echo "Generating self signed certificate for Postfix, please wait..." + openssl req -new -x509 -days 3650 -nodes -subj /commonName=${EE_HOSTNAME}/emailAddress=${EE_EMAIL} -out /etc/ssl/certs/postfix.pem -keyout /etc/ssl/private/postfix.pem &>> $EE_COMMAND_LOG + postconf -e smtpd_tls_cert_file=/etc/ssl/certs/postfix.pem + postconf -e smtpd_tls_key_file=/etc/ssl/private/postfix.pem + }