Skip to content

Commit

Permalink
machine_core: Check for cockpit.socket instead of OSTree for starting…
Browse files Browse the repository at this point in the history
… Cockpit

We want to test the cockpit/ws container with beibooting on other images
than just OSTree. So for deciding whether to start the systemd unit or
the container, check if the unit exists, instead of hardcoding "exactly
OStree uses ws".

Tests currently check the `Machine.ostree_image` flag both for *actual*
specifics of OSTree (such as a read-only /usr) as well as a proxy for
"am I running Cockpit from the container". As this won't coincide in the
future, introduce a new `Machine.ws_container` flag.
  • Loading branch information
martinpitt committed Oct 23, 2024
1 parent a246658 commit 09000b1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions machine/machine_core/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ def start_cockpit(self, *, tls: bool = False) -> None:
allow you to make modifications before it starts.
"""

if self.ostree_image:
# start via cockpit/ws container if cockpit-ws package isn't installed
self.ws_container = not self.execute("systemctl --no-legend list-unit-files cockpit.socket",
check=False).strip()

if self.ws_container:
self.stop_cockpit()
cmd = "podman container runlabel RUN cockpit/ws"
if not tls:
Expand Down Expand Up @@ -284,7 +288,7 @@ def start_cockpit(self, *, tls: bool = False) -> None:
def restart_cockpit(self) -> None:
"""Restart Cockpit.
"""
if self.ostree_image:
if self.ws_container:
self.execute(f"podman restart {self.get_cockpit_container()}")
self.wait_for_cockpit_running()
else:
Expand All @@ -293,7 +297,7 @@ def restart_cockpit(self) -> None:
def stop_cockpit(self) -> None:
"""Stop Cockpit.
"""
if self.ostree_image:
if self.ws_container:
self.execute(f"echo {self.get_cockpit_container()} | xargs --no-run-if-empty podman rm -f")
else:
self.execute("systemctl stop cockpit.socket cockpit.service")
Expand Down

0 comments on commit 09000b1

Please sign in to comment.