LoginSignup
0
0

More than 3 years have passed since last update.

certbot-auto更新スクリプト

Posted at

動作未検証
そのうちやる

#!/bin/bash

DOMAIN='example.com'
SLACK_INCOMING_HOOK='https://hooks.slack.com/services/{hook_id}'
CERTBOT_AUTO='/usr/bin/certbot-auto'
POST_HOOK='sudo /opt/bitnami/ctlscript.sh restart apache'

EXPIRATION=`openssl s_client -connect ${DOMAIN}:443 < /dev/null 2> /dev/null | openssl x509 -text | grep Not | grep -v Before | awk '/Not After : / {print $4, $5, $6, $7, $8}'`

curl -X POST -H 'Content-type: application/json' --data "{'attachments':[{'title':'Start:${DOMAIN} 期限:${EXPIRATION}', 'color':'#0000FF'}]}" ${SLACK_INCOMING_HOOK}

sudo ${CERTBOT_AUTO} renew --post-hook ${POST_HOOK}

if [ $? -eq 0 ] ;then

curl -X POST -H 'Content-type: application/json' --data "{'attachments':[{'title':'Success:${DOMAIN}', 'color':'#00FF00'}]}" ${SLACK_INCOMING_HOOK}

else

curl -X POST -H 'Content-type: application/json' --data "{'attachments':[{'title':'Failed:${DOMAIN}', 'color':'#FF0000'}]}" ${SLACK_INCOMING_HOOK}

fi
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0