Skip to content

Instantly share code, notes, and snippets.

@lucasRolff
Created December 5, 2015 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasRolff/95b044775ee770309abb to your computer and use it in GitHub Desktop.
Save lucasRolff/95b044775ee770309abb to your computer and use it in GitHub Desktop.
#!/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