From 117886a75fdf2cb00ae66047792181d59818d266 Mon Sep 17 00:00:00 2001 From: sanne Date: Mon, 18 Oct 2021 11:11:36 +0200 Subject: [PATCH] spec: Only run worker preun if systemd is running Before, when systemd was not present (for instance in a container), the preun script would error out. This checks if systemd is present and running in the same way the systemd rpm macros do. Fixes #1915 --- osbuild-composer.spec | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osbuild-composer.spec b/osbuild-composer.spec index 62109d422..decb122f8 100644 --- a/osbuild-composer.spec +++ b/osbuild-composer.spec @@ -349,10 +349,11 @@ The worker for osbuild-composer # systemd_preun uses systemctl disable --now which doesn't work well with template services. # See https://github.com/systemd/systemd/issues/15620 # The following lines mimicks its behaviour by running two commands: - -# disable and stop all the worker services -systemctl --no-reload disable osbuild-worker@.service osbuild-remote-worker@.service -systemctl stop "osbuild-worker@*.service" "osbuild-remote-worker@*.service" +if [ -d /run/systemd/system ]; then + # disable and stop all the worker services + systemctl --no-reload disable osbuild-worker@.service osbuild-remote-worker@.service + systemctl stop "osbuild-worker@*.service" "osbuild-remote-worker@*.service" +fi %postun worker # restart all the worker services