mirror of
https://github.com/DeeJanuz/frametop.git
synced 2026-10-06 01:00:06 +02:00
Wait for a new container to finish setting up before entering it
container-up.sh starts the dev container in a scope of its own, so distrobox enter finds it running and skips its wait for distrobox-init. On a fresh install, init was still setting up passwordless sudo when dev-container.sh ran sudo dnf install, and sudo asked for a password with no terminal to read it from. container-up.sh now waits for container_setup_done itself, and the container's sudo calls use -n, so a password prompt fails at once with a clear message. Fixes #9 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3864741f53
commit
85532a54f3
3 files changed
+21
-6
No files matched your search
+18
-3
@@ -6,7 +6,22 @@
|
||||
# `distrobox enter`.
|
||||
box=${FRAME_BOX:-dev}
|
||||
export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/$(id -u)}
|
||||
[ "$(podman container inspect -f '{{.State.Running}}' "$box" 2>/dev/null)" = true ] && exit 0
|
||||
running() { [ "$(podman container inspect -f '{{.State.Running}}' "$box" 2>/dev/null)" = true ]; }
|
||||
running && exit 0
|
||||
podman container exists "$box" 2>/dev/null || exit 0 # not created yet: setup/dev-container.sh does that
|
||||
exec systemd-run --user --scope --quiet --collect --description="$box container (started for Frametop)" \
|
||||
podman start "$box" >/dev/null
|
||||
since=$(date -u +%FT%T)
|
||||
systemd-run --user --scope --quiet --collect --description="$box container (started for Frametop)" \
|
||||
podman start "$box" >/dev/null || exit
|
||||
|
||||
# Every start runs distrobox-init in the container, and `distrobox enter` only waits for it
|
||||
# when it starts the container itself. The first start installs what distrobox needs and sets
|
||||
# up passwordless sudo, which takes a minute or more; until then sudo in the container asks
|
||||
# for a password (issue #9). Later starts take a few seconds.
|
||||
for i in $(seq 600); do
|
||||
podman logs --since "$since" "$box" 2>&1 | grep -q '^container_setup_done' && exit 0
|
||||
running || break
|
||||
[ "$i" = 10 ] && echo "setting up the $box container (the first start takes a few minutes)" >&2
|
||||
sleep 1
|
||||
done
|
||||
echo "the $box container didn't finish starting; see: podman logs $box" >&2
|
||||
exit 1
|
||||
Reference in new issue
Block a user