Created
December 5, 2015 19:31
-
-
Save lucasRolff/95b044775ee770309abb to your computer and use it in GitHub Desktop.
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 | |
ISWWW=true | |
while getopts ":nd:" opt; do | |
case $opt in | |
d) | |
DOMAIN=$OPTARG | |
;; | |
n) | |
ISWWW=false | |
;; | |
\?) | |
echo "Invalid option: -$OPTARG" >&2 | |
exit 1 | |
;; | |
:) | |
echo "Option -$OPTARG requires an argument." >&2 | |
exit 1 | |
;; | |
esac | |
done | |
if [[ $ISWWW = true ]] | |
then | |
WWW="-d www.$DOMAIN" | |
else | |
WWW="" | |
fi | |
cd /root/letsencrypt | |
echo "Fetching user for domain $DOMAIN" | |
USER=$(/bin/cat /etc/userdomains | /bin/grep $DOMAIN | /usr/bin/head -n 1 | /bin/awk '{print $2}') | |
echo "Detected user: $USER" | |
echo "Fetching webroot for domain $DOMAIN" | |
WEBROOT=$(/bin/cat /etc/userdatadomains | /bin/grep ^${DOMAIN} | /bin/awk -F== '{print $5}') | |
echo "Found webroot: $WEBROOT" | |
echo "Generating SSL from Let's Encrypt" | |
./letsencrypt-auto --text --agree-tos --email lucas@hosting4real.net certonly --renew-by-default --webroot --webroot-path ${WEBROOT}/ -d $DOMAIN $WWW | |
echo "Installing SSL for domain ${DOMAIN}" | |
cd /root/scripts | |
./installssl.pl $DOMAIN > /dev/null | |
echo "SSL installed!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment