TSIG_KEY='pp-dns.com'
ERRORS="0"
+RETRIES_GET_ZONE_AFTER_CREATE=5
+WAIT_FOR_ZONE=1
+
declare -a ZONE_FILES=()
# shellcheck disable=SC2034
else
debug "Executing: ${cmd}"
# shellcheck disable=SC2086
- eval ${cmd} 2>&1 | grep -vi 'gpgsql Connection successful'
+ eval ${cmd} || true
+ fi
+
+ local i=0
+ existing=''
+ if [[ "${SIMULATE}" != 'y' ]] ; then
+ while [[ "$i" -lt "${RETRIES_GET_ZONE_AFTER_CREATE}" ]] ; do
+ debug "Waiting for zone '${CYAN}${zone}${NORMAL}' ..."
+ sleep "${WAIT_FOR_ZONE}"
+ existing=$( pdnsutil list-zone "${zone}" 2>&1 | \
+ grep -vi 'gpgsql Connection successful' | \
+ grep -w 'SOA' || true )
+ if [[ -n "${existing}" ]] ; then
+ info "Found SOA for zone '${CYAN}${zone}${NORMAL}': ${existing}"
+ break
+ fi
+ i=$(( i + 1 ))
+ wait "${WAIT_FOR_ZONE}"
+ done
+ if [[ -z "${existing}" ]] ; then
+ error "Did not found SOA for zone '${CYAN}${zone}${NORMAL}' after ${RED}${RETRIES_GET_ZONE_AFTER_CREATE}${NORMAL} seconds."
+ exit 7
+ fi
fi
cmd="pdnsutil set-account \"${zone}\" \"${CUSTOMER}\""
else
debug "Executing: ${cmd}"
# shellcheck disable=SC2086
- eval ${cmd} 2>&1 | grep -vi 'gpgsql Connection successful'
+ eval ${cmd}
fi
cmd="pdnsutil set-kind \"${zone}\" \"master\""
else
debug "Executing: ${cmd}"
# shellcheck disable=SC2086
- eval ${cmd} 2>&1 | grep -vi 'gpgsql Connection successful'
+ eval ${cmd}
fi
cmd="pdnsutil set-meta \"${zone}\" \"SOA-EDIT-API\" \"DEFAULT\""
else
debug "Executing: ${cmd}"
# shellcheck disable=SC2086
- eval ${cmd} 2>&1 | grep -vi 'gpgsql Connection successful'
+ eval ${cmd}
fi
cmd="pdnsutil set-meta \"${zone}\" \"TSIG-ALLOW-AXFR\" \"${TSIG_KEY}\""
else
debug "Executing: ${cmd}"
# shellcheck disable=SC2086
- eval ${cmd} 2>&1 | grep -vi 'gpgsql Connection successful'
+ eval ${cmd}
fi
}