#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