Skip to content

Instantly share code, notes, and snippets.

@kenzo0107
Last active November 16, 2016 00:59
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 kenzo0107/913795f417c2ef666b6114e6c3f82ddc to your computer and use it in GitHub Desktop.
Save kenzo0107/913795f417c2ef666b6114e6c3f82ddc to your computer and use it in GitHub Desktop.
#!/bin/sh
# Slack Channel & Webhook URL
CHANNEL="#xxxxx"
WEBHOOKURL="https://hooks.slack.com/services/XXXXXX/XXXXXXXX/XXXXXXXXXXXXXXXXXX"
#Slackに通知
function slack () {
MESSAGE="$1"
BOTNAME="KS STG Server"
curl -s -S -X POST -d "payload={\"channel\": \"${CHANNEL}\", \"username\": \"${BOTNAME}\", \"text\": \"${MESSAGE}\" }" ${WEBHOOKURL} >/dev/null
}
# letsencrypt ssl authentication renewal log
LOG=/var/log/letsencrypt/renew.log
TMP=tmp.log
echo "[START] $(date '+%Y/%m/%d %H:%M:%S')" >> $LOG 2>&1
message="Lets Encrypt SSL証明書更新"
touch $TMP
/root/certbot/certbot-auto renew --force-renewal && service httpd graceful > $TMP 2>&1
echo 'Success Update SSL. and execute httpd graceful !' >> $LOG 2>&1
message="$message
SSL証明書を強制更新し、 httpd サーバを再起動しました。"
slack "$message"
cat $TMP >> $LOG
rm $TMP
echo "[FINISH] $(date '+%Y/%m/%d %H:%M:%S')" >> $LOG 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment