Created
March 14, 2017 19:43
-
-
Save figassis/41063b1c79b89a7e9b142175c78f5cac to your computer and use it in GitHub Desktop.
Install SSL certificates on Ubuntu with Letsencrypt
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 | |
#Install/issue letsencrypt certificates on Ubuntu 16.04 | |
if [ $# -ne 2 ]; then | |
echo Usage: $0 domain email | |
exit 1 | |
fi | |
domain=$1 | |
email=$2 | |
status=`dpkg -s letsencrypt | grep Status` | |
#Renewal cron assumes no nginx is using port 443. Please modify accordingly for apache and others | |
cronjob='0 */12 * * * root service nginx stop && /opt/certbot-auto renew --quiet --no-self-upgrade && service nginx start' | |
if [ "$status" != "Status: install ok installed" ]; then | |
sudo apt-get -y install letsencrypt | |
sudo echo $cronjob > /etc/cron.d/letsencrypt | |
fi | |
#Certificates will be stored in /etc/letsencrypt/live/domain | |
sudo /opt/certbot-auto certonly -n --standalone -d $domain -m $email --agree-tos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment