22 lines
449 B
Bash
Executable File
22 lines
449 B
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Auto renew letsencrypt certs
|
|
#
|
|
HOSTNAME=`hostname`
|
|
EMAIL="alerts@lhprojects.net"
|
|
OUTPUT=$(letsencrypt renew)
|
|
LE_STATUS=$?
|
|
|
|
echo $OUTPUT >> /var/log/letsencrypt/renew.log
|
|
|
|
if [ "$LE_STATUS" != 0 ]; then
|
|
SUBJECT="CRON: Letsencrypt automated renewal failed on ${HOSTNAME}"
|
|
else
|
|
SUBJECT="CRON: Renewing all letsencrypt certs on ${HOSTNAME}"
|
|
fi
|
|
|
|
echo $OUTPUT | mail -s "$SUBJECT" $EMAIL
|
|
|
|
# Restart nginx
|
|
systemctl restart nginx
|