troglobit / finit

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

Plugin request, add support for chronyd #281

Closed hongkongkiwi closed 2 years ago

hongkongkiwi commented 2 years ago

I need to get the clock synced as early as possible so I created a plugin for chronyd (which is my time service of choice).

My reference can be found here: https://github.com/hongkongkiwi/finit/blob/master/plugins/chronyd.c

troglobit commented 2 years ago

Without looking at the details of the code, do you really need it to be a plugin? Isn't it enough to start it in runlevel [S12345789]? I mean, networking doesn't come up anyway until we move out of S -> 2 ...

hongkongkiwi commented 2 years ago

In this case it’s because mdev runs some scripts and writes some logs. These logs have the wrong time stamp because mdevd starts before chronyd (same issue if using mdev for hot plug).

I suppose I’m running chronyd in place of the RTC plugin at the moment. -- Sent from Gmail Mobile

troglobit commented 2 years ago

Aha, yeah I suppose that's a use-case. I'm a bit hesitant to add this to the main repo, but maybe this fits into your previous idea of having a separate finit-plugins repo for people to pick and choose from?

We have a few plugins we build for my old job, so this could be good idea also to ensure building external plugins continue to work across releases and in release cycles.

hongkongkiwi commented 2 years ago

Yea, it would be great to pool any third party plugins into one place but some (such as qmi-proxy or chronyd might not make sense in the main repo as you say). I bet something like a partition formatting plugin would also be great in the third party section.

Maybe mdevd might maybe need to live in the main repo though as it needs to also be detected by hotplug (to decide whether to run mdevd-coldplug or mdev).

I guess we just have to have an easy way to add in plugins, then for custom codebases one could just add the thirdparty plugins dir as a subrepo maybe.

troglobit commented 2 years ago

Cool, I'll try to set something up during the coming weekend. We'll see what fits where, but like you say, mdevd likely fits better in main.

Subrepo or just build externally to verify exported headers work. I'll give it a go :)

troglobit commented 2 years ago

Looking at setting this up now. Planned to use your chronyd as first plugin, but wouldn't you rather have the copyright set to your own name? I mean the license is probably best to keep the same as Finit, but the copyright ... you wrote this :)

hongkongkiwi commented 2 years ago

Sounds good, thanks for the reminder, I added this to the file, seem ok? Just based on this post.

troglobit commented 2 years ago

That's great! It's a bit of a balancing act, but I guess we're setting prejudice for how to work in that new repo, so better safe than sorry.

In the past, before VCS, people used to write changelogs at the top of each file, denoting what they had modified. Today we have GIT, and so common best practice, I believe is to just add another Copyright line after, in particular for works that are small and changes to an original/template minor. Copyright law, international one in particular, is no walk in the park. As I maintain quite a few projects, I've had to at least take the whirlwind tour ...

troglobit commented 2 years ago

Here we go! :-)

https://github.com/troglobit/finit-plugins