From 14cfad6eee808c54c82d145346299a07a2c767d6 Mon Sep 17 00:00:00 2001 From: srvrco Date: Wed, 4 May 2016 16:33:00 +0100 Subject: [PATCH] Corrections for if DNS_DEL_COMMAND is blank, and typo. --- create-getssl-config | 9 +++++---- getssl | 15 +++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/create-getssl-config b/create-getssl-config index 431439a..61c61bb 100755 --- a/create-getssl-config +++ b/create-getssl-config @@ -18,10 +18,11 @@ # Revision history: # 2016-02-04 Created (v0.1) # 2016-02-05 Updated to include more variables. Still not full operational. (v0.2) +# 2016-05-04 Corrected typo on DNS_DEL_COMMAND (v0.3) # --------------------------------------------------------------------------- PROGNAME=${0##*/} -VERSION="0.2" +VERSION="0.3" # defaults CA="https://acme-staging.api.letsencrypt.org" @@ -353,10 +354,10 @@ VALIDATE_VIA_DNS=$res if [[ $VALIDATE_VIA_DNS == "true" ]]; then get_user_input "DNS add command" "${DNS_ADD_COMMAND}" \ - "location/name of script which will add the token message to DNS" + "location/name of script which will add the token message to DNS" DNS_ADD_COMMAND=$res - get_user_input "DNS add command" "${DNS_DEL_COMMAND}" \ - "location/name of script which will add the token message to DNS" + get_user_input "DNS del command" "${DNS_DEL_COMMAND}" \ + "location/name of script which will delete the token message from DNS" DNS_DEL_COMMAND=$res get_user_input "DNS extra wait time" "${DNS_EXTRA_WAIT}" \ "delay time, to wait for DNS to propagate once changed." diff --git a/getssl b/getssl index 0fe22b0..b355e1a 100755 --- a/getssl +++ b/getssl @@ -46,10 +46,11 @@ # 2016-04-05 Ensure DNS cleanup on error exit. (0.28) - pecigonzalo # 2016-04-15 Remove NS Lookup of A record when using dns validation (0.29) - pecigonzalo # 2016-04-17 Improving the wording in a couple of comments and info statements. (0.30) +# 2016-05-04 Improve check for if DNS_DEL_COMMAND is blank. (0.31) # --------------------------------------------------------------------------- PROGNAME=${0##*/} -VERSION="0.30" +VERSION="0.31" # defaults CA="https://acme-staging.api.letsencrypt.org" @@ -75,7 +76,9 @@ clean_up() { # Perform pre-exit housekeeping rm -rf "${TEMP_DIR:?}" fi if [[ $VALIDATE_VIA_DNS == "true" ]]; then - $DNS_DEL_COMMAND "$d" + if [[ ! -z "$DNS_DEL_COMMAND" ]]; then + $DNS_DEL_COMMAND "$d" + fi fi return } @@ -720,6 +723,7 @@ alldomains=$(echo "$DOMAIN,$SANS" | sed "s/,/ /g") if [[ $VALIDATE_VIA_DNS != "true" ]]; then for d in $alldomains; do debug "checking nslookup for ${d}" + # shellcheck disable=SC2034 exists=$(nslookup "${d}") if [ "$?" != "0" ]; then error_exit "DNS lookup failed for $d" @@ -798,7 +802,10 @@ for d in $alldomains; do # check if we have the information needed to place the challenge if [[ $VALIDATE_VIA_DNS == "true" ]]; then if [[ -z "$DNS_ADD_COMMAND" ]]; then - error_exit "DNS_ADD_COMMAND not defined for domain" + error_exit "DNS_ADD_COMMAND not defined for domain $d" + fi + if [[ -z "$DNS_DEL_COMMAND" ]]; then + error_exit "DNS_DEL_COMMAND not defined for domain $d" fi else if [ -z "${ACL[$dn]}" ]; then @@ -839,7 +846,7 @@ for d in $alldomains; do # find a primary / authoratative DNS server for the domain primary_ns=$(nslookup -type=soa "${d}" | grep origin | awk '{print $3}') - if [ -z $primary_ns ]; then + if [ -z "$primary_ns" ]; then primary_ns=$(nslookup -type=soa "${d}" -debug=1 | grep origin | awk '{print $3}') fi debug primary_ns "$primary_ns"