qdm12 / ddns-updater

Container to update DNS records periodically with WebUI for many DNS providers
https://hub.docker.com/r/qmcgaw/ddns-updater/
MIT License
1.73k stars 164 forks source link

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

Open bcurran3 opened 4 years ago

bcurran3 commented 4 years ago

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

qdm12 commented 4 years ago

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!

bcurran3 commented 4 years ago

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

fredericrous commented 3 years ago

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.

qdm12 commented 3 years ago

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 commented 3 years ago

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.

roopesh commented 2 weeks ago

@qdm12 just checking if the Web UI for updates was ever implemented. I still configure via json and checking if I missed anything :)