Created
September 1, 2016 17:40
-
-
Save gp187/a464017e31818d8a14f6614c1b6b1adf to your computer and use it in GitHub Desktop.
Install letsencrypt and automatically renew certificates monthly
This file contains hidden or 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 | |
# Install: let's encrypt certbot | |
To use run ```install-letsencrypt-autorenew.sh example.com``` and everything will be done for you | |
function install() { | |
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt | |
} | |
function post_install() { | |
# I need port :80 | |
service nginx stop | |
} | |
function install_configs() { | |
# Run: generate certificate | |
[ ! -f /etc/letsencrypt/renewal/${1}.conf ] && { | |
/bin/bash /opt/letsencrypt/letsencrypt-auto certonly --standalone -d ${1} | |
service nginx stop | |
openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048 | |
service nginx start | |
} | |
} | |
function install_services() { | |
# install cron | |
local CRON="/bin/bash /opt/letsencrypt/letsencrypt-auto renew --force-renewal" | |
( crontab -l | grep -v "$CRON" ; echo "0 0 1 * * ${CRON}" ) | crontab - | |
} | |
install | |
post_install | |
install_configs | |
install_services |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment