Skip to content

Instantly share code, notes, and snippets.

@gomasy
Last active January 15, 2020 08:39
Show Gist options
  • Save gomasy/49437c592ae2c09f2d38ecbb167b1acd to your computer and use it in GitHub Desktop.
Save gomasy/49437c592ae2c09f2d38ecbb167b1acd to your computer and use it in GitHub Desktop.
#!/bin/sh
declare -A prev
declare -A next
renewal=0
domain=("gomasy.jp" "gomasy.net")
for d in ${domain[@]}; do
prev+=([$d]=`date -r /etc/letsencrypt/live/$d/cert.pem "+%s"`)
done
certbot renew
for d in ${domain[@]}; do
next+=([$d]=`date -r /etc/letsencrypt/live/$d/cert.pem "+%s"`)
if [[ ${prev[$d]} -ne ${next[$d]} ]]; then
cat /etc/letsencrypt/live/$d/chain.pem /etc/ssl/certs/DST_Root_CA_X3.pem > /etc/ssl/certs/$d-ca-certs.crt
renewal=1
fi
done
if [[ $renewal -eq 1 ]]; then
openssl rand -out /etc/ssl/private/ticket.key 80
systemctl restart nginx
systemctl restart postfix
systemctl restart dovecot
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment