fix: run rootless podman commands as archipelago user in doctor

The doctor runs as root (for tor permissions, process cleanup) but
containers are rootless under the archipelago user. Use sudo -u to
switch user context for podman commands.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-30 22:49:36 +01:00
parent d67c636988
commit 4dd3d29dc4

View File

@@ -369,13 +369,15 @@ print(' '.join(['\"' + a + '\"' if ' ' in a else a for a in args[2:]]))
fix_stopped_core_containers() {
local core_containers="bitcoin-knots lnd electrumx mempool-api archy-mempool-web archy-mempool-db archy-btcpay-db archy-nbxplorer btcpay-server"
local restarted=()
# Doctor runs as root but containers are rootless under archipelago user
local PODMANCMD="sudo -u archipelago XDG_RUNTIME_DIR=/run/user/1000 podman"
for name in $core_containers; do
local state
state=$(podman inspect "$name" --format '{{.State.Status}}' 2>/dev/null || echo "missing")
state=$($PODMANCMD inspect "$name" --format '{{.State.Status}}' 2>/dev/null || echo "missing")
if [ "$state" = "exited" ] || [ "$state" = "stopped" ]; then
log "Restarting stopped container: $name"
podman start "$name" 2>/dev/null && restarted+=("$name") || true
$PODMANCMD start "$name" 2>/dev/null && restarted+=("$name") || true
fi
done