Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.