Comment 5 for bug 2027613

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

# Suggestion to think about

So IMHO you have a service that is neither never nor always (re-)started.
And IMHO the arguments to dh_installsystemd are never enough to express that.

But systemd has mechanisms for such, for example [1].

I haven't dealt with all your config.
There is /var/lib/landscape/client/ and /etc/landscape/client.conf and sometimes landscape-client.conf.
That is up to you to know better which might be good.

Sadly most of the checks are for existence and your files all exist on install, they are just not fully ready yet. I registered a client and compared the config pre/post attach.

I realize that having or not-having account_name in /etc/landscape/client.conf might be the perfect condition. But systemd can't check on file content AFAIK. What would you think of using a /etc/landscape/registered or anything in /var/lib/landscape/client that you think you can rely on to be present "after config" but "before service start".

Gladly systemd adds a special way for everything :-)
For "advanced" conditions there is [2] which you might use here.
And you have - in the new version - gladly `landscape-config --is-registered`

I'm not sure how this internally works, --is-registered needs to be able to return true after being configured, but before the service has been started. I think you check /var/lib/landscape/client/broker.bpickle which might only exist after the first start, but I'm sure you could work something out that solves this and then would really cover all use-cases better.

As an example something like the following might cover all of the above cases much better (please check and amend with your subject matter expertise):

$ git diff
diff --git a/debian/landscape-client.service b/debian/landscape-client.service
index 6dc721a3..aa5c0261 100644
--- a/debian/landscape-client.service
+++ b/debian/landscape-client.service
@@ -11,6 +11,7 @@ WantedBy=multi-user.target
 [Service]
 Type=simple
 Group=landscape
+ExecCondition=/usr/bin/landscape-config --is-registered
 ExecStart=/usr/bin/landscape-client
 # Don't kill cgroup as child dpkg may restart the service during an upgrade.
 KillMode=process
diff --git a/debian/rules b/debian/rules
index ad30f5c9..d6a156c6 100755
--- a/debian/rules
+++ b/debian/rules
@@ -23,4 +23,4 @@ override_dh_auto_install:
        install -D -o root -g root -m 755 apt-update/apt-update $(CURDIR)/$(root_dir)$(LIBDIR)/apt-update

 override_dh_installsystemd:
- dh_installsystemd --no-enable --no-start --no-stop-on-upgrade
+ dh_installsystemd

[1]: https://www.freedesktop.org/software/systemd/man/systemd.unit.html#ConditionFileNotEmpty=
[2]: https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecCondition=