diff --git a/seqs/mailserver.sh b/seqs/mailserver.sh index 8ca8a2c..da98eac 100755 --- a/seqs/mailserver.sh +++ b/seqs/mailserver.sh @@ -34,8 +34,9 @@ step_config() { echo " Domain: $MAS_DOMAIN" elif [ $? -eq 1 ] ; then # Config $CONFIG_FILE_NAME created. Needs modification first - [ $DRY -eq 0 ] && return 1 + [ $DRY -eq 0 ] && return -1 fi + return 0 } step_1_info() { echo "Update apt repositories"; } @@ -73,11 +74,11 @@ step_4() { step_5_info() { echo "$mtaName enable submission service"; } step_5() { - echo -e " [I] Copy following lines...\n" + echoseq -e " [I] Copy following lines...\n" exe cat "$mtaConfSubmission" exe read -rep $'\nPress Enter to open the '$mtaConfLoc'/master.cf' exe vi $mtaConfLoc/master.cf - exe echo + exe echoseq exe cat "$mtaConfSmtps" exe read -rep $'\nPress Enter to open the '$mtaConfLoc'/master.cf' exe vi $mtaConfLoc/master.cf @@ -96,97 +97,108 @@ step_6() { exe postconf "smtp_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1" exe postconf "smtp_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1" - echo " [I] Restarting $mtaName" + echoseq " [I] Restarting $mtaName" exe service $mtaName restart } -step_7_info() { echo "Install $mdaName"; } +step_7_info() { + echo "Restrict client access" + echoinfo "Mainly PTR record check" +} step_7() { - exe apt install $mdaDeps - echo -e "\n [I] Installed version: $(dovecot --version)" + exe postconf -e "smtpd_client_restrictions = permit_mynetworks, reject_unknown_client_hostname" } -step_8_info() { +step_8_info() { echo "Install $mdaName"; } +step_8() { + exe apt install $mdaDeps + echoseq -e "\n [I] Installed version: $(dovecot --version)" +} + +step_9_info() { echo "Configure $mdaName" } -step_8() { - echo "# Configuring Mailbox Location" - echo " [/etc/dovecot/conf.d/10-mail.conf]" - echo " mail_location = maildir:~/Maildir" - echo " mail_privileged_group = mail" - echo - echo " usermod -aG mail dovecot" - echo - echo "# Configuring Authentication Mechanism" - echo " [/etc/dovecot/conf.d/10-auth.conf]" - echo " disable_plaintext_auth = yes" - echo " # Login with full mail address" - echo " auth_username_format = %n" - echo " # "login" to support older mail clients" - echo " auth_mechanisms = plain login" - echo - echo "# Configure SSL/TLS Encryption" - echo " [/etc/dovecot/conf.d/10-ssl.conf]" - echo " ssl = required" - echo " ssl_cert = "$mtaMysqlConfLoc/${mtaFile}.cf" done @@ -255,7 +267,7 @@ step_23() { exe chown -R ${MAS_VIRTUAL_USER}: "$MAS_VIRTUAL_FOLDER_BASE" exe chmod -R 770 "$MAS_VIRTUAL_FOLDER_BASE" - echo " [I] Restarting $mtaName" + echoseq " [I] Restarting $mtaName" exe service $mtaName restart } @@ -331,7 +343,7 @@ step_50() { exe postconf -e "smtp_sasl_password_maps = hash:$saslPassFile" addConf -s "$MAS_RELAYHOST $MAS_RELAYUSER:$MAS_RELAYPASS" "$saslPassFile" fi - echo " [I] Updating $saslPassFile" + echoseq " [I] Updating $saslPassFile" exe postmap "$saslPassFile" } saslPassFile="$mtaConfLoc/sasl_password" @@ -350,7 +362,7 @@ step_52() { echo " smtpd_relay_restrictions =" echo " check_client_access hash:$mtaClientAccessLoc" fi - echo " [I] Updating $mtaClientAccessLoc" + echoseq " [I] Updating $mtaClientAccessLoc" exe postmap "$mtaClientAccessLoc" } mtaClientAccessLoc="$mtaConfLoc/client_access" @@ -361,14 +373,14 @@ step_54_info() { step_54_alias() { ALIAS="recipient_access"; } step_54() { if [ ! -f "$mtaRecipientAccessLoc" ] ; then - echo " [I] Generating $mtaRecipientAccessLoc" + echoseq " [I] Generating $mtaRecipientAccessLoc" exep "echo \"# unwanted@${MAS_DOMAIN} 550 No mailbox. Nothing to see here.\" > \"$mtaRecipientAccessLoc\"" echo " [I] Don't forget to add the following" echo " [$mtaConfLoc/main.cf]" echo " smtpd_recipient_restrictions =" echo " check_recipient_access hash:$mtaRecipientAccessLoc" fi - echo " [I] Updating $mtaRecipientAccessLoc" + echoseq " [I] Updating $mtaRecipientAccessLoc" exe postmap "$mtaRecipientAccessLoc" } mtaRecipientAccessLoc="$mtaConfLoc/recipient_access" @@ -377,7 +389,7 @@ step_56_info() { echo "Add sender dependant relay with authentication"; } step_56_alias() { ALIAS="sender_relay"; } step_56() { if [ ! -f "$mtaSenderRelayLoc" ] ; then - echo " [I] Generating $mtaSenderRelayLoc" + echoseq " [I] Generating $mtaSenderRelayLoc" exep "echo \"# user@extern.com smtp:[mail.extern.com]:587\" > \"$mtaSenderRelayLoc\"" exe postconf -e "smtp_sender_dependent_authentication = yes" exe postconf -e "sender_dependent_relayhost_maps = hash:$mtaSenderRelayLoc" @@ -390,7 +402,7 @@ step_56() { echo " user@extern.com username:passwort" echo " postmap $saslPassFile" fi - echo " [I] Updating $mtaSenderRelayLoc" + echoseq " [I] Updating $mtaSenderRelayLoc" exe postmap "$mtaSenderRelayLoc" exe postmap "$saslPassFile" } @@ -450,5 +462,5 @@ step_104() { exe postsuper -d "$msgId" } -VERSION_SEQREV=11 +VERSION_SEQREV=12 . /usr/local/bin/sequencer.sh