ddns-scripts: allow setting CloudFlare 'rec_id' in the config

This is necessary when there are multiple records for the same domain,
otherwise the script will overwrite the first one returned by the API.
It has the secondary benefit of allowing faster updates by performing
only one API call instead of two.

In case 'rec_id' is not set the script behaves exactly as before.

Signed-off-by: Leonardo Brondani Schenkel <leonardo@schenkel.net>
(grafted from 019ba13d01e93c18d0ed35b0aeb3399f28108e0e)
This commit is contained in:
Leonardo Brondani Schenkel 2016-01-08 19:47:57 +01:00
parent 25de619b04
commit 57ba3be8e0

View file

@ -57,6 +57,7 @@ cleanup() {
sed -i "#'##g" $DATFILE # remove "'" (single quote)
}
[ -n "$rec_id" ] && __RECID="$rec_id" || {
# build url according to cloudflare client api at https://www.cloudflare.com/docs/client-api.html
# to "rec_load_all" to detect rec_id needed for update
__URL="https://www.cloudflare.com/api_json.html" # https://www.cloudflare.com/api_json.html
@ -106,6 +107,7 @@ done
json_get_var __RECID "rec_id" # last thing to do get rec_id
json_cleanup # cleanup
write_log 7 "rec_id '$__RECID' detected for host/domain '$domain'"
}
# build url according to cloudflare client api at https://www.cloudflare.com/docs/client-api.html
# for "rec_edit" to update IP address