Last active
October 20, 2021 08:23
-
-
Save orrisroot/2f9a5012f6e75efc88bb3470446ad413 to your computer and use it in GitHub Desktop.
Service restart script for Let's encrypt renewal hooks (deploy)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SERVICE_NAME=postfix | |
SERVICE_DOMAINS=example.com | |
IS_ACTIVE=$(systemctl is-active ${SERVICE_NAME}) | |
if [ "${IS_ACTIVE}" != "active" ]; then | |
exit 0 | |
fi | |
RESTART=0 | |
for rdomain in ${RENEWED_DOMAINS}; do | |
for sdomain in ${SERVICE_DOMAINS}; do | |
if [ "${rdomain}" = "${sdomain}" ]; then | |
RESTART=1 | |
break 2 | |
fi | |
done | |
done | |
if [ ${RESTART} -eq 0 ]; then | |
exit 0 | |
fi | |
# SSL certificate for ${SERVICE_NAME} was modified. | |
systemctl restart ${SERVICE_NAME} | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment