troglobit / finit

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

Set fixed conditions in device tree? #311

Closed hongkongkiwi closed 1 year ago

hongkongkiwi commented 1 year ago

I would like to set some conditions in finit based on whats in the device tree.

This way certain services can be started based on hardware configuration.

Do you think a finit plugin is the best task for this or do you think it makes sense to have this as a built in feature? If it's in a finit plugin, could you give me a code snipped to set a condition at an early stage? (I would like to set these just after fs are mounted)

e.g. have a finit section in the dtb:

finit {
   conditions={
      conditiona;
      conditionb;
      conditionc;
   };
};
troglobit commented 1 year ago

It could definitely be a plugin, but I don't think you'll need it.

At $OLDJOB we did this, which was pretty neat. The first two links is the common call to set up a static/one-shot condition based on the product model and the third is an example of how to use it:

Remember, static/one-shot conditions are always asserted, following the current configuration generation.

troglobit commented 1 year ago

I've added this to the v4.4 release with the intent of documenting the above trick.