ddns-updater icon indicating copy to clipboard operation
ddns-updater copied to clipboard

FEATURE REQUEST: add config.json blank template in the image

Open bcurran3 opened this issue 4 years ago • 6 comments

Another idea for simpler setup:

When /updater/data/config.json is not found, copy a default template config.json stored in the image to /updater/data/config.json

bcurran3 avatar May 21 '20 21:05 bcurran3

Thanks for the suggestion!

Although I'm planning on having a web UI to input records (so no more dealing with the json file) so the user would just have to create a data directory (or use a future built-in docker anonymous volume, so no need to any setup). I'll try to finish this up this weekend/next week. Otherwise I'll do that feature request you suggest!

qdm12 avatar May 22 '20 02:05 qdm12

touch data/config.json 👎 make default config.json available 👍 web UI for setup 👍 👍 👍 👍 👍 👍

bcurran3 avatar May 22 '20 03:05 bcurran3

as a side note, if a webui is built to configure the records, I would advocate keeping the possibility to configure the records through json and env variables as it is today. Indeed, I believe people who use dynamic dns updater(s) are more likely to prefer configuration files and command lines over web UI. IMO a web UI that displays information is super cool, but a UI that allows me to update the configuration is a plus I would fancy but don't really need. Indeed I rely heavily on Configuration As Code for my homelab setup (everything is automated with ansible + docker swarm). I bet a lot of users are in a similar case, am I right?

Otherwise, regarding the original idea of this feature request, it looks good to me ^^. Let's note it will change the actual behavior of ddns-updater. Today if the config is not found, the program starts and throws an error and exit.

fredericrous avatar Jan 27 '21 17:01 fredericrous

If there is a web ui, we would still need state so keeping the JSON file as is (maybe add some other fields on top of settings) is the goal here 😉 But thanks for the input!

For the empty file, we can just create an empty json file if it doesn't exist at start. I don't think anyone cares if the program doesn't crash if the file is not found retro-compatibility wise 😄

{"settings": []}

But note I'm still at 0% on that, I would first need to set up an http API server to fiddle with its state. And this is blocked by a bunch of things in my head 🤯 😄

qdm12 avatar Jan 27 '21 23:01 qdm12

To accommodate a future-to-be UI, the program was changed as follows:

  1. If the config file does not exist, it is created with content {}. Note that the directory containing it is not created, so it will fail in this case if the directory doesn't exist for example.
  2. If CONFIG has some valid value, it is written to the file as indented JSON (as of 1e74dc6179f12bbaeaace0acbea4342d4fcea60e)
  3. The program runs even if you have no settings (designed as such to add things through the UI).
  4. The CONFIG value still takes precedence over the file. This is problematic if we have the UI since this one would modify the file, but not CONFIG. I'm thinking of swapping the precedence around, any suggestion?

Thanks! I'll close the issue soon.

qdm12 avatar Jun 30 '21 01:06 qdm12