troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
621 stars 61 forks source link

Pass `env:foo` also to pre/post scripts #248

Closed troglobit closed 2 years ago

troglobit commented 2 years ago

Discussed in https://github.com/troglobit/finit/discussions/240

Originally posted by **hongkongkiwi** April 20, 2022 I couldn't find my answer in the docs. Are env:.... variables passed to the pre/post scripts also? I'm interested in having one place for the vars and using them both in pre: and also running the app.
troglobit commented 2 years ago

Turns out this was partially implemented in #189, back in February, also for v4.3 ... so I'll just rip out the SERVICE_ENV_FILE* stuff and replace it with the variables sourced instead. Basically:

sh -ac '. /path/to/env; exec ./pre-post.sh'

This means the env file can be a simple foo=bar file, which Finit can read and call setenv() on all variables, and the user do not need to call export on all variables -- additionally, any functions defined in an env file could be used by the pre-post scripts, but would go ignored by Finit.

hongkongkiwi commented 2 years ago

Nice! That should make things very flexible.