This commit is contained in:
Rene Luria 2020-09-21 09:18:07 +02:00
parent 3601f0e9fc
commit 659011bda1
No known key found for this signature in database
GPG Key ID: FFA540631A620B59

View File

@ -77,8 +77,8 @@ dns_infomaniak_add() {
fi fi
tmpfile=$(mktemp -u) tmpfile=$(mktemp -u)
mkfifo "$tmpfile" mkfifo "$tmpfile"
echo "$zone_and_id" > "$tmpfile" & echo "$zone_and_id" >"$tmpfile" &
read -r zone domain_id < "$tmpfile" read -r zone domain_id <"$tmpfile"
rm "$tmpfile" rm "$tmpfile"
# extract first part of domain # extract first part of domain
@ -151,16 +151,16 @@ dns_infomaniak_rm() {
fi fi
tmpfile=$(mktemp -u) tmpfile=$(mktemp -u)
mkfifo "$tmpfile" mkfifo "$tmpfile"
echo "$zone_and_id" > "$tmpfile" & echo "$zone_and_id" >"$tmpfile" &
read -r zone domain_id < "$tmpfile" read -r zone domain_id <"$tmpfile"
rm "$tmpfile" rm "$tmpfile"
# extract first part of domain # extract first part of domain
key=${fulldomain%.$zone} key=${fulldomain%.$zone}
# find previous record # find previous record
record_id=$(_get "${INFOMANIAK_API_URL}/1/domain/$domain_id/dns/record" \ record_id=$(_get "${INFOMANIAK_API_URL}/1/domain/$domain_id/dns/record" |
| jq -r ".data[] | select(.source_idn == \"$fulldomain\") | .id") jq -r ".data[] | select(.source_idn == \"$fulldomain\") | .id")
if [ -z "$record_id" ]; then if [ -z "$record_id" ]; then
_err "could not find record to delete" _err "could not find record to delete"
return 1 return 1
@ -168,7 +168,7 @@ dns_infomaniak_rm() {
_debug "record_id: $record_id" _debug "record_id: $record_id"
# API call # API call
response=$(_post "" "${INFOMANIAK_API_URL}/1/domain/$domain_id/dns/record/$record_id" "" DELETE) response=$(_post "" "${INFOMANIAK_API_URL}/1/domain/$domain_id/dns/record/$record_id" "" DELETE)
if [ -n "$response" ] && echo "$response" | grep -qF '"result":"success"'; then if [ -n "$response" ] && echo "$response" | grep -qF '"result":"success"'; then
_info "Record deleted" _info "Record deleted"
return 0 return 0
@ -182,8 +182,8 @@ dns_infomaniak_rm() {
_get_domain_id() { _get_domain_id() {
domain="$1" domain="$1"
_get "${INFOMANIAK_API_URL}/1/product?service_name=domain&customer_name=$domain" \ _get "${INFOMANIAK_API_URL}/1/product?service_name=domain&customer_name=$domain" |
| jq -r '.data[].id' jq -r '.data[].id'
} }
_find_zone() { _find_zone() {