From: Leonid Krivoshein <klark.devel@gmail.com> To: make-initrd@lists.altlinux.org Subject: Re: [make-initrd] [PATCH v1 21/41] fork pipeline: bootchain sysvinit script now use external hooks Date: Tue, 28 Sep 2021 03:40:34 +0300 Message-ID: <49aa03c4-c94d-53fe-c595-5ce605dca197@gmail.com> (raw) In-Reply-To: <245f1b4c-b417-11b7-57c3-6650ade2ef75@gmail.com> [-- Attachment #1: Type: text/plain, Size: 2982 bytes --] 27.09.2021 20:22, Leonid Krivoshein пишет: > > 27.09.2021 16:57, Alexey Gladkov пишет: >> On Mon, Sep 27, 2021 at 04:11:43PM +0300, Leonid Krivoshein wrote: >>> [...] >>>>> Другим компонентам bootchain при расширении (а теперь это уже более >>>>> десятка фич и подпакетов) тоже может потребоваться подобная >>>>> инициализация. >>>>> Здесь в одном коммите видно, куда переехал код функции prepare(). >>>>> Хуки нужны >>>>> для того, чтобы вызывать подобную инициализацию из определённого >>>>> места, так >>>>> как базовый пакет bootchain-core может не знать, с какими >>>>> компонентами >>>>> bootchain собран initramfs. Соответственно, включаемые скрипты >>>>> кладутся в >>>>> /lib/bootchain-prepare.d. Если потребуется, по аналогии можно >>>>> добавить в >>>>> stop() хуки для деинициализации. >>>> https://github.com/osboot/make-initrd/blob/master/data/etc/rc.d/rc#L32-L38 >>>> >>>> https://github.com/osboot/make-initrd/blob/master/data/etc/rc.d/rc#L61 >>>> https://github.com/osboot/make-initrd/blob/master/data/etc/rc.d/rc#L109 >>>> >>>> https://github.com/osboot/make-initrd/blob/master/data/etc/rc.d/rc#L114 >>>> >>>> >>>> Ты имеешь в виду вот такие хуки ? >>> Ну очень похожие, хотя use_hooks() явно проще -- без блокировки >>> консоли, без >>> бита выполнения, просто соурсим исходники: >> Эти хуки уже давно есть и можно использовать. Не нужно дублировать >> этот же >> функционал. > > Дойдя до этого места не понял, как их можно использовать... > > Делаю скрипт выполняемым, а класть-то его куда? В > /lib/initrd/pre/bootchain-core/ ? > Проверочная сборка показала, что этот путь не работает. Если загрузиться с параметрами waitdev=UUID=1234 waitdev_timeout=180 rdshell и запустить из rdshell руками /lib/initrd/pre/bootchain-core/300-waitdev , только тогда видно, что правильно отрабатывает. Но автоматом хук не запускается. В коде есть механизм запуска, но он не используется ни в одной фиче и в data/ его тоже нет, только сам этот скрипт rc. Вот изменения, на всякий случай: -- Best regards, Leonid Krivoshein. [-- Attachment #2: waitdev.diff --] [-- Type: text/x-patch, Size: 1916 bytes --] commit d5340fea7efcf9995b7391a17b9781462556e661 Author: Leonid Krivoshein <klark@altlinux.org> Date: Tue Sep 28 00:14:28 2021 +0300 core+waitdev: use common way for hooks call instead internal use_hooks() See also: https://lists.altlinux.org/pipermail/make-initrd/2021-September/000685.html diff --git a/bootchain-core/data/etc/rc.d/init.d/bootchain b/bootchain-core/data/etc/rc.d/init.d/bootchain index 7bdb1cf..1538339 100755 --- a/bootchain-core/data/etc/rc.d/init.d/bootchain +++ b/bootchain-core/data/etc/rc.d/init.d/bootchain @@ -17,24 +17,9 @@ NAME=bootchained PIDFILE="/var/run/$NAME.pid" ARGS="--lockfile $LOCKFILE --pidfile $PIDFILE --name $NAME --displayname $NAME" -use_hooks() -{ - local hook hdir="$1" - - if [ -d "$hdir" ]; then - # shellcheck disable=SC2012 - for hook in $(ls -1 -- "$hdir"/* |sort) _; do - [ -s "$hook" ] || - continue - . "$hook" - done - fi -} - start() { RETVAL=0 if [ "${ROOT-}" = bootchain ] || [ "${ROOT-}" = pipeline ]; then - use_hooks /lib/bootchain-prepare.d start_daemon --background $ARGS "$NAME" RETVAL=$? fi diff --git a/bootchain-waitdev/data/lib/bootchain-prepare.d/300-waitdev b/bootchain-waitdev/data/lib/initrd/pre/bootchain-core/300-waitdev old mode 100644 new mode 100755 similarity index 71% rename from bootchain-waitdev/data/lib/bootchain-prepare.d/300-waitdev rename to bootchain-waitdev/data/lib/initrd/pre/bootchain-core/300-waitdev index f7315a3..5e0f040 --- a/bootchain-waitdev/data/lib/bootchain-prepare.d/300-waitdev +++ b/bootchain-waitdev/data/lib/initrd/pre/bootchain-core/300-waitdev @@ -1,10 +1,13 @@ #!/bin/bash -efu +. /.initrd/initenv + dir=/.initrd/bootchain/waitdev mkdir -p -- "$dir" [ -z "${WAITDEV_TIMEOUT-}" ] || - printf '%s\n' "$WAITDEV_TIMEOUT" >"$dir/TIMECNT" + printf '%s\n' "$WAITDEV_TIMEOUT" >"$dir"/TIMECNT + i=0 while [ "$i" -lt "${WAITDEV:-0}" ]; do touch "$dir/$i"
next prev parent reply other threads:[~2021-09-28 0:40 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-24 15:57 Leonid Krivoshein 2021-09-26 14:09 ` Alexey Gladkov 2021-09-26 19:53 ` Leonid Krivoshein 2021-09-27 9:09 ` Alexey Gladkov 2021-09-27 13:11 ` Leonid Krivoshein 2021-09-27 13:57 ` Alexey Gladkov 2021-09-27 17:22 ` Leonid Krivoshein 2021-09-28 0:40 ` Leonid Krivoshein [this message] 2021-09-28 7:11 ` Leonid Krivoshein
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=49aa03c4-c94d-53fe-c595-5ce605dca197@gmail.com \ --to=klark.devel@gmail.com \ --cc=make-initrd@lists.altlinux.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Make-initrd development discussion This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/make-initrd/0 make-initrd/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 make-initrd make-initrd/ http://lore.altlinux.org/make-initrd \ make-initrd@lists.altlinux.org make-initrd@lists.altlinux.ru make-initrd@lists.altlinux.com public-inbox-index make-initrd Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.make-initrd AGPL code for this site: git clone https://public-inbox.org/public-inbox.git