diff --git a/debian/resources/letsencrypt.sh b/debian/resources/letsencrypt.sh index 5c482f3..cc3b124 100755 --- a/debian/resources/letsencrypt.sh +++ b/debian/resources/letsencrypt.sh @@ -53,6 +53,11 @@ if [ .$wilcard_domain = ."true" ]; then fi fi +#copy config and hook.sh into /etc/dehydrated +cd /usr/src/dehydrated +cp docs/examples/config /etc/dehydrated +#cp docs/examples/hook.sh /etc/dehydrated + #update the dehydrated config #sed "s#CONTACT_EMAIL=#CONTACT_EMAIL=$email_address" -i /etc/dehydrated/config sed -i' ' -e s:'#CONTACT_EMAIL=":CONTACT_EMAIL=$email_address:' /etc/dehydrated/config @@ -64,30 +69,27 @@ dehydrated --register --accept-terms --config /etc/dehydrated/config #set the domain alias domain_alias=$(echo "$domain_name" | head -n1 | cut -d " " -f1) +#create an alias when using wildcard dns +if [ .$wilcard_domain = ."true" ]; then + echo "*.$domain_name > $domain_name" > /etc/dehydrated/domains.txt +fi + #add the domain name to domains.txt if [ .$wilcard_domain = ."false" ]; then echo "$domain_name" > /etc/dehydrated/domains.txt fi -#copy config and hook.sh into /etc/dehydrated -cd /usr/src/dehydrated -cp docs/examples/config /etc/dehydrated -#cp docs/examples/hook.sh /etc/dehydrated +#request the certificates +if [ .$wilcard_domain = ."true" ]; then + dehydrated --cron --domain *.$domain_name --alias $domain_alias --config /etc/dehydrated/config --out /etc/dehydrated/certs --challenge dns-01 --hook /etc/dehydrated/hook.sh +fi +if [ .$wilcard_domain = ."false" ]; then + dehydrated --cron --alias $domain_alias --config /etc/dehydrated/config --config /etc/dehydrated/config --out /etc/dehydrated/certs --challenge http-01 +fi #make sure the nginx ssl directory exists mkdir -p /etc/nginx/ssl -#accept the terms -dehydrated --register --accept-terms --config /etc/dehydrated/config - -#request the certificates -if [ .$wilcard_domain = ."true" ]; then - dehydrated --cron --domain *.$domain_name --alias $domain_name --config /etc/dehydrated/config --out /etc/dehydrated/certs --challenge dns-01 --hook /etc/dehydrated/hook.sh -fi -if [ .$wilcard_domain = ."false" ]; then - dehydrated --cron --domain $domain_name --config /etc/dehydrated/config --config /etc/dehydrated/config --out /etc/dehydrated/certs --challenge dns-01 --hook /etc/dehydrated/hook.sh -fi - #update nginx config sed "s@ssl_certificate /etc/ssl/certs/nginx.crt;@ssl_certificate /etc/dehydrated/certs/$domain_name/fullchain.pem;@g" -i /etc/nginx/sites-available/fusionpbx sed "s@ssl_certificate_key /etc/ssl/private/nginx.key;@ssl_certificate_key /etc/dehydrated/certs/$domain_name/privkey.pem;@g" -i /etc/nginx/sites-available/fusionpbx