Skip to content

Instantly share code, notes, and snippets.

@user454322
Last active May 27, 2021 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save user454322/3b76136805ccb57ec1b8162bf91eb511 to your computer and use it in GitHub Desktop.
Save user454322/3b76136805ccb57ec1b8162bf91eb511 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#set -e
#openssl s_client -starttls smtp -showcerts -connect email.example.com:25 -servername email.example.com
#openssl x509 -in /etc/ssl/email.example.com.fullchain.pem -text
readonly LOG_PATH='/var/log/acme-cert-renew.log'
readonly DOMAIN='example.com'
echo '::::::::::::::::::::::' | ts | tee -a "$LOG_PATH"
echo 'Starting to renew cert' | ts | tee -a "$LOG_PATH"
rcctl -f start httpd |& ts | tee -a "$LOG_PATH"
echo 'Waiting..' | ts | tee -a "$LOG_PATH"
sleep 10
/usr/sbin/acme-client -v "$DOMAIN" |& ts | tee -a "$LOG_PATH"
echo 'Waiting after ...' | ts | tee -a "$LOG_PATH"
sleep 180
rcctl stop httpd |& ts | tee -a "$LOG_PATH"
echo 'Done renewing cert' | ts | tee -a "$LOG_PATH"
/etc/rc.d/smtpd restart |& ts | tee -a "$LOG_PATH"
tail -15 "$LOG_PATH" | mail -s "Email renewal certificate" root
#exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment