diff --git a/SubModules/postfix/Postfix-EnableSSL.sh b/SubModules/postfix/Postfix-EnableSSL.sh new file mode 100644 index 0000000..7bd2e61 --- /dev/null +++ b/SubModules/postfix/Postfix-EnableSSL.sh @@ -0,0 +1,32 @@ +#Sript for setting up SSL/TLS for Postfix (Web-V2) + +##Loading install vars +source /etc/ICTM/mainvar.list +##Checking if hostname cert exists +if [ ! -f "/etc/acmesh/inst/$hostname/cert.pem" ] || [ ! -f "/etc/acmesh/inst/$hostname/key.pem" ] ; then echo 'SSL Certificate for $hostname is not installed' && exit ; fi + +##Updating Postix config +printf "Updating Postfix config" +systemctl stop postfix +sed -i "/smtpd_tls_cert_file=/c\ssmtpd_tls_cert_file=/etc/acmesh/inst/$hostname/cert.pem" /etc/postfix/main.cf +sed -i "/smtpd_tls_key_file=/c\smtpd_tls_key_file=/etc/acmesh/inst/$hostname/key.pem" /etc/postfix/main.cf +systemctl start postfix +printf " [\e[1;32m Ok \e[0m]\n" + +##Adding postfix to SSL services (so it gets reloaded when a the cert is renewd) +printf "Updating SSL services list" +echo "postfix" >> /etc/ICTM/SslServices +printf " [\e[1;32m Ok \e[0m]\n" + +##Remove script +while true; do + read -p "Remove this script -> yes/no?" yn + case $yn in + [Nn]* ) + break;; + [Yy]* ) + rm -- "$0" + break;; + * )echo "Choose yes or no.";; + esac +done \ No newline at end of file diff --git a/SubModules/postfix/conf.sh b/SubModules/postfix/conf.sh index f0d622c..7ccc6b6 100644 --- a/SubModules/postfix/conf.sh +++ b/SubModules/postfix/conf.sh @@ -90,6 +90,9 @@ chmod +x /etc/update-motd.d/51-generalspf systemctl start postfix opendkim systemctl enable postfix opendkim +#Getting script for enableling ssl on Postfix +curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/postfix/Postfix-EnableSSL.sh -o ~/Postfix-EnableSSL.sh + #if using Append module run for existing cms/sites if [ "$itype" = "AddMod" ]; then for file in /etc/ICTM/sites/*; do