2023-06-20 21:45:14 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# certbot deploy hook to copy certificates to mail4one when renewed.
|
2023-06-28 16:54:50 -04:00
|
|
|
# Initial setup, Install certbot(https://certbot.eff.org/) and run `certbot certonly` as root
|
2023-12-20 17:21:57 -05:00
|
|
|
# Doc: https://eff-certbot.readthedocs.io/en/latest/using.html#renewing-certificates
|
2023-06-28 16:54:50 -04:00
|
|
|
#
|
2023-06-20 21:45:14 -04:00
|
|
|
# This file is supposed to be copied to /etc/letsencrypt/renewal-hooks/deploy/
|
|
|
|
# Change the mail domain to the one on MX record
|
|
|
|
|
|
|
|
if [ "$RENEWED_DOMAINS" = "mail.mydomain.com" ]
|
|
|
|
then
|
|
|
|
mkdir -p /var/lib/mail4one/certs
|
2023-06-24 20:12:20 -04:00
|
|
|
chmod 750 /var/lib/mail4one/certs
|
2023-06-20 21:45:14 -04:00
|
|
|
chown mail4one:mail4one /var/lib/mail4one/certs
|
|
|
|
cp "$RENEWED_LINEAGE/fullchain.pem" /var/lib/mail4one/certs/
|
|
|
|
cp "$RENEWED_LINEAGE/privkey.pem" /var/lib/mail4one/certs/
|
|
|
|
systemctl restart mail4one.service
|
2023-12-20 17:21:57 -05:00
|
|
|
echo "$(date) Renewed and deployed certificates for mail4one" >> /var/log/mail4one-cert-renew.log
|
2023-06-20 21:45:14 -04:00
|
|
|
fi
|