Last active
November 16, 2016 00:59
-
-
Save kenzo0107/913795f417c2ef666b6114e6c3f82ddc to your computer and use it in GitHub Desktop.
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/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