On Tue, 4 Jan 2022 at 14:40, David <bouncingc...@gmail.com> wrote:

> There are a couple of unexpected aspects to script #2, which I will
> explain ...
>
> a) Script sequencing
>
> or "Why has he put it under /usr ?"
>
> All the PREREQ= and prereqs stuff is a mechanism to control the
> sequencing of scripts in each subdirectory under
> '*/initramfs-toos/scripts/'.
>
> How to use that mechanism will depend on how the other scripts present
> are already using it. Above I left it unused because I had to use a
> different approach, so PREREQ was irrelevant and I never assigned it
> any values. This seems common in other scripts too, when order does
> not matter.
>
> For my situation it was essential to ensure that Step #2 ran before
> the interactive cryptsetup password prompt script in the initrd.
>
> So I had to take note of where that occurs in the whole sequence of
> different subdirectories, and ensure that my script ran before.
>
> And a complicating factor is that 'man initramfs-tools' says:
>
>   Please notice that PREREQ is only honored inside a single directory.
>   So first the scripts in /usr/share/initramfs-tools are ordered
>   according to their PREREQ values and executed. Then all scripts in
>   /etc/initramfs-tools are ordered according to their PREREQ values and
>   executed. This mean that currently there is no possibility to have a
>   local script (/etc/initramfs-tools) get executed before one from the
>   package (/usr/share/initramfs-tools).
>
> Note the last sentence. Even though I suspect it ambiguously
> overstates the problem, that explains why my script *must* be placed
> in '/usr/..../local-top' subdirectory and not under /etc as would be
> more desirable. I could not see any way to have it under /etc and
> be sure that it would run early enough. I tried that, and it worked.

Realised that I forgot to articulate something important
in that explanation ...

The other "boot script"
  /usr/share/initramfs-tools/scripts/local-top/cryptroot
is what provides the interactive cryptsetup password prompt.
And it contains prereqs() logic to ensure that it runs
*last* of all scripts in that '/usr/.../local-top' directory.

That is why my my_kdbrate script:
- must be in that directory /usr...local-top, so it runs before;
- cannot be placed under /etc, which would run after;
- does not need to specify any PREREQ, already managed.

Reply via email to