troglobit / finit

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

Feature request, Allow additional directories included in config with include /etc/finit.d/*.conf #184

Open hongkongkiwi opened 3 years ago

hongkongkiwi commented 3 years ago

Hi there,

I would like to use the "include" feature to include another finit.d directory.

In my case, I would like to include both /etc/finit.d and /mnt/flash/etc/finit.d. Users are only allowed to edit files in /mnt/flash/etc/finit.d .

Could I propose that the "include" config also allows directories as well as files? or that we have a separate includedir config.

Can I also suggest that we have a '-' flag (like with env files), so we can allow it to include without this (and just ignore the file or directory being missing) or if '-' is passed then it will error if the include file or directory is not passed.

So it could be like this:

include -/mnt/flash/etc/finit.conf
include /mnt/flash/etc/finit-is-optional.conf
includedir -/mnt/flash/etc/finit.d
includedir /mnt/flash/etc/finit.d-dir-is-optional
troglobit commented 3 years ago

Like the env issue, this is a neat idea but a lot of work. Finit has a built-in dependency handler that monitors the configuration for changes so it's ready when a user issues reload, supporting more/any directory is a lot of work and nothing I've got time or interest to do myself.

What could be interesting is a glob like feature, like include /etc/finit.d/*.conf or something, but there is currently no plan for that either.

hongkongkiwi commented 3 years ago

I do have another request which may deserve it's own issue? I would love to just simply change the finit.d directory in the bootstrap config. Right now I have to hardcode during compilation. Is there any reason that it's done this way rather than a config?

The way I've worked around the issue now is to setup all system services in the bootstrap /etc/finit.conf file, then hardcoded finit to look in /mnt/flash/etc/finit.d

This works well, but I have two devices using the same core image, one has services on /mnt/flash/etc/finit.d and one is on /mnt/mmcblk0p1/etc/finit.d rather than having two compiled versions of finit, it would be nice to change this in a config file instead.

troglobit commented 3 years ago

The reason is simply because we have no use for it ourselves, and supporting all possible variant in every case is not sustainable.

hongkongkiwi commented 2 years ago

Hi, just wanted to follow up on this.

Adding support for dynamic directories definitely sounds like a bit of work, with lots of cases where things could go wrong.

Could I modify the idea a little bit.... Is it possible to add support for adding some additional fixed RCSD directories as part of the compile stage? .e.g. --with-rcsd="/etc/finit.d,/config/finit.d"

This way I could specify one or more additional directories to search. Then when your reloading or watching updated files, you have a fixed number of directories to watch and search that won't ever change.

troglobit commented 2 years ago

Either way, it's a lot of work and will not be in the upcoming v4.4 release. (I'm actually about to start the -rc phase.)

Have you considered setting up OverlayFS instead? Your /mnt/flash/etc could overlay /etc and you'd have an editable /etc without all this additional complexity.

Here's what I do in myLinux, notice the use of mount helpers (extra config option in BusyBox):

hongkongkiwi commented 2 years ago

I didn't think of overlayfs, it could be a good option depending on CPU usage (we are quite limited in this regard). I'll look into it.

Thanks for the examples.

troglobit commented 2 years ago

We've used overlayfs on NXP i.MX27 (Armv5 no L2 cache), without any issues. Very quick to mount and gives the illusion of a regular system. Users love it.

Notice the last section of the mnt script. We have a small C program, called "factory" that can be used as login shell (for a factory/reset user/pass), shell tool for users in a given group, or a regular tool for the root user to touch a file on /mnt and trigger a reboot to erase any changes made to the device having left the factory.