Open zodac opened 3 months ago
Hey @zodac ,
Great idea, but I would need some help. This was discussed in this issue: https://github.com/jokob-sk/NetAlertX/issues/669#issuecomment-2105382077
Quote:
Number 3) I'm more then happy if you or someone helps me to achieve a universal way how to initialize any setting via an ENV variable. This has to be done dynamically as new settings are introduced constantly and maintaining the code otherwise would become unsustainable. This also means when users save the given settings in the UI it may be overridden again - so corresponding UI warnings should ideally be shown.
Hmm... I haven't gone through the code in depth, but is there a check for the initial run of the system? If not, that could be added, and the environment variables only applied the very first time. That would allow the UI updates to not be overridden on a restart?
I did see something in main.py for some variables being defaulted, like SCAN_SUBNETS. Could we do something like that for all values in app.conf, and only use default values where no environment variable is set?
I did see something in main.py for some variables being defaulted, like SCAN_SUBNETS. Could we do something like that for all values in app.conf, and only use default values where no environment variable is set?
Sure, that's possible, but again, this has to be done dynamically - something like:
Think about what the priority of those values should be, e.g.:
app.conf fvalue > env value > default value. Not sure, think about it :)
Here is probably the place where ENV variables should be checked: https://github.com/jokob-sk/NetAlertX/blob/f9b16081d69c6aa6ce0661d3011af6c85c952304/server/initialise.py#L31
if I may jump in...
@zodac @FlyingToto @sbe-arg I just pushed an experimental implementation of this. If you have time, please check the netalertx-dev
image in about 15 min from now:
- APP_CONF_OVERRIDE={"SCAN_SUBNETS":"['192.168.1.0/24 --interface=eth1']","UI_dark_mode":"True"}
The JSON can't have spaces between key:value pairs.
Is there an existing issue for this?
Am I willing to test this? ๐งช
netlertx-dev
image when requested within 48h and report bugs to help deliver a great user experience for everyone and not to break existing installations.Can I help implement this? ๐ฉโ๐ป๐จโ๐ป
Is your feature request related to a problem? Please describe
It would be great if we could configure NetAlertX through environment variables. If I'm deploying a fresh install, having to reconfigure everything from the UI can be a bit of a pain.
Describe the solution you'd like
If an environment variable is set matching a value in app.conf (such as SCAN_SUBNETS or SMTP_RUN), it populates the application configuration on first start-up.
Describe alternatives you've considered
Configuring an app.conf file and passing that into the container is also an option, though the current one says not to update it, and might break on upgrades.
Anything else?
I didn't see any issues around this, so apologies if it's been brought up before. The UI does mention each parameter in the appropriate settings section, so perhaps it is meant to work already, and I haven't configured things correctly?