Last active
September 22, 2021 04:45
-
-
Save SuperPaintman/6dcb286cee1d50b13e3dacab01ac33a8 to your computer and use it in GitHub Desktop.
Auto renew Let's Encrypt throw Docker
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 | |
# | |
# Author: SuperPaintman <[email protected]> | |
# | |
### | |
# Constants | |
### | |
RETVAL=0 | |
CCYAN="\033[0;36m" | |
CGREEN="\033[0;32m" | |
CBLUE="\033[0;34m" | |
CGRAY="\033[1;30m" | |
CNC="\033[0m" | |
docker_container_name="letsencrypt" | |
update_domain () { | |
local config_file=$1 | |
echo -e "${CGREEN}Start${CNC} ${CBLUE}${config_file}${CNC}" | |
docker run --name $docker_container_name \ | |
--rm \ | |
-v /etc/letsencrypt:/etc/letsencrypt \ | |
-v /usr/share:/ust/share \ | |
-v /var/www/letsencrypt:/var/www/letsencrypt \ | |
quay.io/letsencrypt/letsencrypt auth --config "$config_file" --keep --renew-by-default | |
} | |
if [ "$1" ] ; then | |
# Config from argv | |
update_domain "$1" | |
else | |
# Config from etc | |
array=($(find /etc/letsencrypt/configs/*.ini -type f)) | |
for element in "${array[@]}" ; do | |
update_domain "$element" | |
done | |
fi | |
echo -e "${CGREEN}Restart Nginx${CNC}" | |
docker restart nginx | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment