Skip to content

feat(init.sh): progress, failure handling and safe uploads for onboot commands - #199

Merged
HappyBasher merged 3 commits into
7.4from
feat/onboot-progress
Oct 24, 2026
Merged

HappyBasher merged 3 commits into
7.4from
feat/onboot-progress

Conversation

@HappyBasher

Copy link
Copy Markdown
Member

Summary

Onboot commands (linbo-remote -p) during the splash:

  • Progress in the splash (9ab96b4): init.sh passed the output line by line to plymouth --update. qemu-img, rsync and pv redraw their progress with \r, buildtorrent with \b, so nothing was shown until a step ended; pv's zero filling (stderr) never reached the splash. run_with_status() turns every redraw into a status line (tr '\r\b' '\n\n', busybox tr is unbuffered); on the console the output is shown as is. stdout no longer goes to init.log (no progress lines in the log), stderr still does. linbo_create_image shows pv's progress on stdout.
  • Failed onboot commands (a2be6c2): the exit status was ignored. Now a failed command is logged with its rc and the last ten lines of its stdout (progress bars reduced to their last state), and the remaining onboot commands are skipped like with linbo-remote -c, e.g. no upload after a failed image creation.
  • No upload of incomplete images (dea35d6): linbo_upload only checked that the image exists. Now a qcow2/qdiff is only uploaded if imagesize in its info file matches the file size (complete creation or download); linbo_create_image removes the incomplete image when the compression fails. The .complete marker cannot be used: since aria2c (replace ctorrent with aria2c #152) only linbo_create_image sets it.

Follow-up to #133 / #198.

Test plan

  • Shell suite green under dash and busybox ash (new: test_init.sh 9, test_linbo_upload.sh 5)
  • Simulation on multi-1: status lines arrive live for pv, qemu-img (23 → 98 % over two minutes), buildtorrent and rsync
  • Onboot block of the new init.sh on multi-1 with upload_image:2::zzbad,reboot and a dummy image without info file: upload refused as incomplete, failure + last output logged, reboot skipped
  • Test package of this branch on lmnsrv1 + multi-1: splash progress checked by @HappyBasher

🤖 Generated with Claude Code

Onboot commands (linbo-remote -p) and linbo_autoinitcache passed their
output line by line to print_status. The progress bars of qemu-img, rsync
and pv redraw their line with \r and buildtorrent with \b, so "while
read" held them back until the next newline: the splash showed e.g. the
compression or upload message for minutes without any progress, and the
zero filling of pv, drawn on stderr, not at all.

run_with_status() now shows the stdout of these commands: in the splash
every redraw becomes a status line of its own (tr '\r\b' '\n\n', blank
pieces dropped), on the console the output goes as is to /dev/console,
which draws the bars in place. stdout no longer goes to init.log in the
console mode either, so the log gets no progress lines; stderr is left
alone and keeps error messages in the log.

linbo_create_image shows the progress of pv on stdout like the other
steps, dd's own messages stay on stderr.

Covered by tests/shell/test_init.sh.

Signed-off-by: [email protected]
Assisted-by: Claude
init.sh ignored the exit status of the onboot commands: a failed command
was not logged, its messages on stdout were only shown in the splash,
and the remaining commands still ran, e.g. the upload of an image whose
creation had just failed.

run_with_status() now keeps the stdout of the command in
/tmp/run_with_status.out and returns the exit status of the command
(pipefail in its subshell only). If an onboot command fails, init.sh
logs it with its rc and the last ten lines of its stdout, every progress
bar reduced to its last state by last_output_lines(), and skips the
remaining onboot commands like linbo-remote -c does.

linbo_autoinitcache is not checked, its exit status is 1 whenever there
is nothing to do.

Signed-off-by: [email protected]
Assisted-by: Claude
linbo_upload only checked that the image file exists. After an aborted
creation the incomplete qcow2 stayed in the cache and could be uploaded,
replacing the good image on the server.

linbo_upload now uploads a qcow2/qdiff image only if its info file
exists and its imagesize is the actual size of the image. A completely
created or downloaded image always has a matching info file, an aborted
creation has the info file of the former version or, under a new name,
none at all. The .complete marker cannot be used: since aria2c (#152)
only linbo_create_image sets it, downloaded images do not have it.

linbo_create_image removes the incomplete image when the compression
fails.

Covered by tests/shell/test_linbo_upload.sh.

Signed-off-by: [email protected]
Assisted-by: Claude
@HappyBasher
HappyBasher merged commit 5e1cc09 into 7.4 Oct 24, 2026
6 checks passed
@HappyBasher
HappyBasher deleted the feat/onboot-progress branch October 24, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant