From 66ef83023498efc9904673967385354e6a18f231 Mon Sep 17 00:00:00 2001 From: magges Date: Sun, 12 Jul 2026 23:20:30 +0000 Subject: [PATCH] Fix Settings service chip showing "Not running" right after a successful start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rc_podman()'s "is it running" check only recognized rc.podman status's own "service: running (pid ..., socket ...)" wording — but start/stop/restart print differently-worded messages of their own ("start: already running (pid ...)", "stop: stopped", ...), which never matched that same regex. Found live: a successful Start Podman click (podman already running, correctly a no-op) still turned the chip red because its own success message didn't say "service:". Now always runs a fresh `status` check after the requested verb (unless the verb WAS status) to determine "running", instead of trying to regex-parse each verb's differently-worded own output. Co-Authored-By: Claude Sonnet 5 --- webui/plugins/podman/ajax/settings.php | 27 +++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/webui/plugins/podman/ajax/settings.php b/webui/plugins/podman/ajax/settings.php index 6848406..16b5314 100644 --- a/webui/plugins/podman/ajax/settings.php +++ b/webui/plugins/podman/ajax/settings.php @@ -86,6 +86,25 @@ switch ($action) { * @return array{running: bool, output: string} */ function rc_podman(string $verb, int $timeoutSeconds): array +{ + $output = run_rc_podman($verb, $timeoutSeconds); + + // Only `rc.podman status` prints the "service: running + // (pid ..., socket ...)" line this regex looks for — start/stop/ + // restart's OWN messages are worded differently ("start: already + // running (pid ...)", "stop: stopped", ...), so relying on THIS same + // regex against THEIR output silently reported "not running" right + // after a successful start (found live: a start that printed "start: + // already running" turned the status chip red). Always running a + // fresh `status` afterward — regardless of which verb was actually + // requested — is the one output format this check can trust. + $statusOutput = $verb === 'status' ? $output : run_rc_podman('status', 15); + $running = (bool) preg_match('/service:\s+running/', $statusOutput); + + return ['running' => $running, 'output' => $output]; +} + +function run_rc_podman(string $verb, int $timeoutSeconds): string { $descriptors = [1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; $process = proc_open([RC_PODMAN, $verb], $descriptors, $pipes); @@ -100,13 +119,7 @@ function rc_podman(string $verb, int $timeoutSeconds): array fclose($pipes[2]); proc_close($process); - $combined = trim($stdout . $stderr); - // rc.podman status/start both print "service: running (pid ..., socket ...)" - // on success — cheaper and more honest than re-implementing the same - // socket/pid check PHP-side when the shell script already did it. - $running = (bool) preg_match('/service:\s+running/', $combined); - - return ['running' => $running, 'output' => $combined]; + return trim($stdout . $stderr); } /** @return array */