FarrowStrange / hetzner-api-dyndns

A small script to dynamically update DNS records using the Hetzner DNS-API.
GNU General Public License v3.0
136 stars 38 forks source link

jq v1.5 creates dupblicate A-records #29

Open fajabird opened 1 year ago

fajabird commented 1 year ago

I'm running the script on a ubuntu server LTS 18.04 which only has jq version 1.5-1-a5b5cbe.

  1. when I run the script I get following output which is very strange because a) it shows that the script does find the jq command but still I get:

root@server1:/usr/local/bin# ./dyndns.sh Info: Record_Name: server1 : Zone_ID: Info: Record_Name: server1 : Zone_Name: Info: Record_Name: server1 : Using IPv4, because A was set as record type. Info: Record_Name: server1 : Current public IP address: jq - commandline JSON processor [version 1.5-1-a5b5cbe] Usage: jq [options] [file...]

jq is a tool for processing JSON inputs, applying the
given filter to its JSON text inputs and producing the
filter's results as JSON on standard output.
The simplest filter is ., which is the identity filter,
copying jq's input to its output unmodified (except for
formatting).
For more advanced filters see the jq(1) manpage ("man jq")
and/or https://stedolan.github.io/jq

Some of the options include:
 -c     compact instead of pretty-printed output;
 -n     use `null` as the single input value;
 -e     set the exit status code based on the output;
 -s     read (slurp) all inputs into an array; apply filter to it;
 -r     output raw strings, not JSON texts;
 -R     read raw strings, not JSON texts;
 -C     colorize JSON;
 -M     monochrome (don't colorize JSON);
 -S     sort keys of objects on output;
 --tab  use tabs for indentation;
 --arg a v  set variable $a to value <v>;
 --argjson a v  set variable $a to JSON value <v>;
 --slurpfile a f    set variable $a to an array of JSON texts read from <f>;
See the manpage for more options.

Info: Record_Name: : Record_ID: DNS record "" does not exists - will be created. {"record":{"id":"","type":"","name":"","value":"","zone_id":"","created":"","modified":""},"error":{"message":"422 Unprocessable Entity: taken: ; ","code":422}}

I guess the last line means that some part of the input cannot be processed by that jq version? Is there a workaround that will work with this version?

dr4hcu5-jan commented 1 year ago

To me it seems like you are neither supplying a zone name nor a zone ID. Furthermore, it seems like you are not setting a record name (e.g. @, *). Therefore the JSON generated may be wrong.

The last line means that the Hetzner API rejected your request since there is information missing in the request, but the request is not malformed. See the MDN page here.

tho22 commented 1 year ago

I had the same problem. You must use the JQ V1.6. I simply replaced the binary in my environment with the current JQ: https://stedolan.github.io/jq/download/

magoralczyk commented 1 year ago

I can also confirm that. It is a little weird to replace the original 22kb file with a 4MB file, but it worked like tho22 described.

thcrt commented 9 months ago

Running ./dyndns.sh without any arguments will always fail. It needs a zone and a record to be specified. Zones may be specified with either ID or name, while records may be specified with either or both.

Perhaps this still would not have worked if you had passed the correct arguments, but the given example would not have worked anyway. I'm also confused as to why the issue is titled referencing 'duplicate A records' but you don't mention anything about that in the issue itself. Maybe this has since been fixed by #30?