From 07af8d58745a121052cab49c70a476f02996da1e Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Wed, 3 May 2023 22:21:38 +0200 Subject: [PATCH] fix(dracut-lib.sh): remove successful finished initqueue scripts If some "finished" initscripts keep failing, dracut will start printing warnings after a while. But it will warn about all scripts in the finished initqueue, not only those that have failed. That makes it difficult to identify the script that has actually caused the failure. To avoid this, delete finished initqueue scripts when they succeed. Also, instead of returning as soon as one of the scripts fails, try all scripts, deleting those that succeed, and return failure if at least one script failed. If a previously deleted script is recreated by some other part of the code, it will be re-run the next time the check_finished() function is called, and will be re-deleted if it still succeeds. The only case where I see that this might cause issues is if some condition needs to be tested over and over again, because it succeeds and then fails later (for example, a device showing up and then being removed again). But I think that this is not the intended logic. In general, when a device shows up or another "finished" condition is met, we assume that this condition will hold at least until the initramfs switches root and exits. If all conditions are met, the current code will also exit the initqueue without retrying any of the conditions again. --- modules.d/99base/dracut-lib.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index 14f20d78a..6eaa0fe14 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -410,13 +410,17 @@ source_hook() { } check_finished() { - local f + local f rc=0 for f in "$hookdir"/initqueue/finished/*.sh; do [ "$f" = "$hookdir/initqueue/finished/*.sh" ] && return 0 # shellcheck disable=SC1090 - { [ -e "$f" ] && (. "$f"); } || return 1 + if [ -e "$f" ] && (. "$f"); then + rm -f "$f" + else + rc=1 + fi done - return 0 + return $rc } source_conf() { -- 2.47.2