Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build snapraid config files through container variables #7

Open
mgutt opened this issue Aug 27, 2023 · 0 comments
Open

Build snapraid config files through container variables #7

mgutt opened this issue Aug 27, 2023 · 0 comments

Comments

@mgutt
Copy link

mgutt commented Aug 27, 2023

For Unraid it would be much easier for the user if it would be possible to manipulate the snapraid config through container variables.

Is it possible to parse all passed container variables dynamically? By that it would be possible to do this:

-e RUNNER_SNAPRAID_TOUCH=true
...
-e RUNNER_NOTIFICATION_SHORT=true
-e RUNNER_NOTIFICATION_URL=[true](discord://ID/Token)
...
-e CONFIG_PARITY=/mnt/HDD4/snapraid.parity
-e CONFIG_PARITY2=/mnt/HDD5/snapraid.2-parity
-e CONFIG_CONTENT=/config/snapraid.content
-e CONFIG_CONTENT2=/mnt/HDD1/snapraid.content
-e CONFIG_EXCLUDE=/tmp/
-e CONFIG_EXCLUDE2=/lost+found/

And then parse similar to this:

for key, value in args:
  key = key.lower()
  parts= key.split('_'):
  if parts[0] is "runner":
   # fill dict with config data of snapraid-runner.conf
  else if parts[0] is "config":
    # fill dict with config data of snapraid.conf  

# now create the two config files based on the variables...

All CONFIG variables ending to a number create additional lines. For example "CONFIG_CONTENT2" does not become "content2 /mnt/HDD1/snapraid.content". Instead it becomes "content /mnt/HDD1/snapraid.content" in a new line.

And as long no "CONFIG_..." or "RUNNER_..." variable is passed, the already existing config files are left untouched. By that this change would not break anything for already existing setups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant