From daa7c6b69ffe51d11256f22c101eb9225e1c079f Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sat, 21 Jul 2018 00:18:39 -0600 Subject: [PATCH] Update letsencrypt.sh --- freebsd/resources/letsencrypt.sh | 83 +++++++++++++++++--------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/freebsd/resources/letsencrypt.sh b/freebsd/resources/letsencrypt.sh index 9610989..5f7a0ec 100755 --- a/freebsd/resources/letsencrypt.sh +++ b/freebsd/resources/letsencrypt.sh @@ -23,14 +23,6 @@ cd "$(dirname "$0")" read -p 'Domain Name: ' domain_name read -p 'Email Address: ' email_address -#wildcard detection -wilcard_domain=$(echo $domain_name | cut -c1-1) -if [ "$wilcard_domain" = "*" ]; then - wilcard_domain="y" -else - wilcard_domain="n" -fi - #get and install dehydrated pkg install dehydrated #cd /usr/src && git clone https://github.com/lukas2511/dehydrated.git @@ -39,16 +31,6 @@ pkg install dehydrated #mkdir -p /usr/local/www/dehydrated #mkdir -p /usr/local/etc/dehydrated/certs -#remove the wildcard and period -if [ .$wilcard_domain = ."y" ]; then - domain_name=$(echo "$domain_name" | cut -c3-255) -fi - -#create an alias when using wildcard dns -#if [ .$wilcard_domain = ."y" ]; then -# echo "*.$domain_name > $domain_name" > /usr/local/etc/dehydrated/domains.txt -#fi - #manual dns hook cd /usr/src git clone https://github.com/owhen/dns-01-manual.git @@ -67,13 +49,31 @@ cp docs/examples/config /usr/local/etc/dehydrated #accept the terms dehydrated --register --accept-terms --config /usr/local/etc/dehydrated/config +#wildcard detection +wilcard_domain=$(echo $domain_name | cut -c1-1) +if [ "$wilcard_domain" = "*" ]; then + wilcard_domain="true" +else + wilcard_domain="false" +fi + +#remove the wildcard and period +if [ .$wilcard_domain = ."true" ]; then + domain_name=$(echo "$domain_name" | cut -c3-255) +fi + +#create an alias when using wildcard dns +#if [ .$wilcard_domain = ."true" ]; then +# echo "*.$domain_name > $domain_name" > /usr/local/etc/dehydrated/domains.txt +#fi + #wildcard domain -if [ .$wilcard_domain = ."y" ]; then +if [ .$wilcard_domain = ."true" ]; then dehydrated --cron --domain *.$domain_name --alias $domain_name --config /usr/local/etc/dehydrated/config --out /usr/local/etc/dehydrated/certs --challenge dns-01 --hook /usr/local/etc/dehydrated/hook.sh fi #single domain -if [ .$wilcard_domain = ."n" ]; then +if [ .$wilcard_domain = ."false" ]; then dehydrated --cron --domain $domain_name --config /usr/local/etc/dehydrated/config --config /usr/local/etc/dehydrated/config --out /usr/local/etc/dehydrated/certs --challenge dns-01 --hook /usr/local/etc/dehydrated/hook.sh fi @@ -90,28 +90,31 @@ cp /usr/local/etc/dehydrated/certs/$domain_name/privkey.pem /usr/local/etc/nginx #read the config /usr/local/sbin/nginx -t && /usr/local/sbin/nginx -s reload -#make sure the freeswitch directory exists -mkdir -p /usr/local/etc/freeswitch/tls +#setup freeswitch tls +if [ .$switch_tls = ."true" ]; then + #make sure the freeswitch directory exists + mkdir -p /usr/local/etc/freeswitch/tls -#make sure the freeswitch certificate directory is empty -rm /usr/local/etc/freeswitch/tls/* + #make sure the freeswitch certificate directory is empty + rm /usr/local/etc/freeswitch/tls/* -#combine the certs into all.pem -cat /usr/local/etc/dehydrated/certs/$domain_name/fullchain.pem > /usr/local/etc/freeswitch/tls/all.pem -cat /usr/local/etc/dehydrated/certs/$domain_name/privkey.pem >> /usr/local/etc/freeswitch/tls/all.pem -#cat /usr/local/etc/dehydrated/certs/$domain_name/chain.pem >> /usr/local/etc/freeswitch/tls/all.pem + #combine the certs into all.pem + cat /usr/local/etc/dehydrated/certs/$domain_name/fullchain.pem > /usr/local/etc/freeswitch/tls/all.pem + cat /usr/local/etc/dehydrated/certs/$domain_name/privkey.pem >> /usr/local/etc/freeswitch/tls/all.pem + #cat /usr/local/etc/dehydrated/certs/$domain_name/chain.pem >> /usr/local/etc/freeswitch/tls/all.pem -#copy the certificates -cp /usr/local/etc/dehydrated/certs/$domain_name/cert.pem /usr/local/etc/freeswitch/tls -cp /usr/local/etc/dehydrated/certs/$domain_name/chain.pem /usr/local/etc/freeswitch/tls -cp /usr/local/etc/dehydrated/certs/$domain_name/fullchain.pem /usr/local/etc/freeswitch/tls -cp /usr/local/etc/dehydrated/certs/$domain_name/privkey.pem /usr/local/etc/freeswitch/tls + #copy the certificates + cp /usr/local/etc/dehydrated/certs/$domain_name/cert.pem /usr/local/etc/freeswitch/tls + cp /usr/local/etc/dehydrated/certs/$domain_name/chain.pem /usr/local/etc/freeswitch/tls + cp /usr/local/etc/dehydrated/certs/$domain_name/fullchain.pem /usr/local/etc/freeswitch/tls + cp /usr/local/etc/dehydrated/certs/$domain_name/privkey.pem /usr/local/etc/freeswitch/tls -#add symbolic links -ln -s /usr/local/etc/freeswitch/tls/all.pem /usr/local/etc/freeswitch/tls/agent.pem -ln -s /usr/local/etc/freeswitch/tls/all.pem /usr/local/etc/freeswitch/tls/tls.pem -ln -s /usr/local/etc/freeswitch/tls/all.pem /usr/local/etc/freeswitch/tls/wss.pem -ln -s /usr/local/etc/freeswitch/tls/all.pem /usr/local/etc/freeswitch/tls/dtls-srtp.pem + #add symbolic links + ln -s /usr/local/etc/freeswitch/tls/all.pem /usr/local/etc/freeswitch/tls/agent.pem + ln -s /usr/local/etc/freeswitch/tls/all.pem /usr/local/etc/freeswitch/tls/tls.pem + ln -s /usr/local/etc/freeswitch/tls/all.pem /usr/local/etc/freeswitch/tls/wss.pem + ln -s /usr/local/etc/freeswitch/tls/all.pem /usr/local/etc/freeswitch/tls/dtls-srtp.pem -#set the permissions -chown -R www:www /usr/local/etc/freeswitch/tls + #set the permissions + chown -R www:www /usr/local/etc/freeswitch/tls +fi