This commit is contained in:
Gassan Gousseinov 2020-05-17 22:51:04 +02:00
parent fa91516dce
commit b82c48b66f

View File

@ -56,8 +56,8 @@ dns_hetzner_add() {
else else
_info "Found record id: $_record_id." _info "Found record id: $_record_id."
_info "Record found, do nothing." _info "Record found, do nothing."
return 0; return 0
# # we could modify a record, if the names for txt records for *.example.com and example.com would be not the same # we could modify a record, if the names for txt records for *.example.com and example.com would be not the same
#if _hetzner_rest PUT "records/${_record_id}" "{\"zone_id\":\"${HETZNER_Zone_ID}\",\"type\":\"TXT\",\"name\":\"$full_domain\",\"value\":\"$txt_value\",\"ttl\":120}"; then #if _hetzner_rest PUT "records/${_record_id}" "{\"zone_id\":\"${HETZNER_Zone_ID}\",\"type\":\"TXT\",\"name\":\"$full_domain\",\"value\":\"$txt_value\",\"ttl\":120}"; then
# if _contains "$response" "$txt_value"; then # if _contains "$response" "$txt_value"; then
# _info "Modified, OK" # _info "Modified, OK"
@ -107,12 +107,12 @@ dns_hetzner_rm() {
#returns #returns
# _record_id=a8d58f22d6931bf830eaa0ec6464bf81 if found; or 1 if error # _record_id=a8d58f22d6931bf830eaa0ec6464bf81 if found; or 1 if error
_find_record() { _find_record() {
unset _record_id; unset _record_id
_record_name=$1 _record_name=$1
_record_value=$2 _record_value=$2
if [ -z "$_record_value" ]; then if [ -z "$_record_value" ]; then
_record_value="[^\"]*" _record_value='[^"]*'
fi fi
_debug "Getting all records" _debug "Getting all records"
@ -129,7 +129,7 @@ _find_record() {
| while read -r record; do | while read -r record; do
# test for type and # test for type and
if [ -n "$(echo "$record" | _egrep_o '"type":"TXT"')" ]; then if [ -n "$(echo "$record" | _egrep_o '"type":"TXT"')" ]; then
echo "$record" | _egrep_o "\"id\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \" echo "$record" | _egrep_o '"id":"[^"]*"' | cut -d : -f 2 | tr -d \"
break break
fi fi
done done
@ -160,7 +160,7 @@ _get_root() {
unset HETZNER_Zone_ID unset HETZNER_Zone_ID
else else
if _contains "$response" "\"id\":\"$HETZNER_Zone_ID\""; then if _contains "$response" "\"id\":\"$HETZNER_Zone_ID\""; then
_domain=$(printf "%s\n" "$response" | _egrep_o "\"name\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \" | head -n 1) _domain=$(printf "%s\n" "$response" | _egrep_o '"name":"[^"]*"' | cut -d : -f 2 | tr -d \" | head -n 1)
if [ "$_domain" ]; then if [ "$_domain" ]; then
_cut_length=$((${#domain} - ${#_domain} - 1)) _cut_length=$((${#domain} - ${#_domain} - 1))
_sub_domain=$(printf "%s" "$domain" | cut -c "1-$_cut_length") _sub_domain=$(printf "%s" "$domain" | cut -c "1-$_cut_length")