Last active
February 19, 2016 00:17
-
-
Save kacchan822/b03a0b7770eda085524e to your computer and use it in GitHub Desktop.
letsencrypt_cert_autoupdate
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/bash | |
# | |
# Copyright (c) 2016 Katsuya SAITO | |
# This software is released under the MIT License. | |
# http://opensource.org/licenses/mit-license.php | |
# | |
# @(#) letsencrypt_cert_autoupdate_webroot.sh ver.0.1.0 2016.01.31 | |
# | |
# Usage: | |
# | |
# | |
# | |
# Description: | |
# | |
# | |
# | |
# | |
############################################################################### | |
# CONFIGER SECTION #----------------------------------------------------------# | |
readonly CMD_PATH=/usr/local/letsencrypt | |
readonly LOG_FILE=/var/log/letsencrypt/renew.log | |
readonly SERVER_RESTART_CMD='/etc/init.d/nginx restart' # After update CA, How to restart WEB Server? | |
# Default set is for NGINX | |
readonly CN="exsample.com" # Your Common Name for CA | |
readonly WEB_ROOT_PATH=/var/www/html # WEB ROOT Path | |
readonly MAIL_TO="root" # Mail to update result. | |
# Default set is Local USER ROOT! | |
#-----------------------------------------------------------------------------# | |
# SCRIPT SECTION #------------------------------------------------------------# | |
today=`date +%F-%a-%T` | |
echo "# Let's Encrypt Cert autopudate Start: ${today}" >${LOG_FILE} | |
echo "# Update Log START --------------------------------------------------------------#" >>${LOG_FILE} | |
${CMD_PATH}/letsencrypt-auto certonly --renew-by-default --webroot -w ${WEB_ROOT_PATH} -d ${CN} >>${LOG_FILE} 2>&1 | |
echo >>${LOG_FILE} | |
echo "# WEB SERVER RESTART LOG START ------------------------------#" >>${LOG_FILE} | |
${SERVER_RESTART_CMD} >> ${LOG_FILE} | |
echo "#---------------------------- WEB SERVER RESTART LOG END ---#" >>${LOG_FILE} | |
echo "#------------------------------------------------------------- Update Log END ---#" >>${LOG_FILE} | |
today=`date +%F-%a-%T` | |
echo "# Let's Encrypt Cert autopudate End: ${today}" >>${LOG_FILE} | |
cat ${LOG_FILE} | mail -s "[Let's Encrypt Auto Update] Update Report for ${CN}" ${MAIL_TO} | |
exit 0 | |
#-----------------------------------------------------------------------------# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-------- Report Message Sample --------
-------- Report Message Sample --------