/etc/systemd/system/lookup-domain.service invalid syntax in unit file

Operating system Fedora Linux 43
Webmin version 2.610
Usermin version 2.510
Virtualmin version 7.50.3 GPL
Authentic theme version 26.20

Virtualmin deploys the lookup-domain service, in the unit file there is a ExecStop command, it uses invalid syntax &&, given the unit files ExecStop is not executed in a shell, the && is not valid syntax.

~# cat /etc/systemd/system/lookup-domain.service
[Unit]
Description=Daemon for quickly looking up Virtualmin servers from procmail

[Service]
ExecStart=/usr/sbin/virtualmin lookup-domain-daemon
ExecStop=test -s /var/webmin/lookup-domain-daemon.pid && /bin/kill `cat /var/webmin/lookup-domain-daemon.pid`
Type=forking

[Install]
WantedBy=multi-user.target

Replacing the ExecStop line with:

ExecStop=/bin/sh -c 'test -s /var/webmin/lookup-domain-daemon.pid && kill "$(cat /var/webmin/lookup-domain-daemon.pid)"'

is correct syntax and should fix the issue

Steven

Edit: some typos / unclear title

If you use /usr/bin/test instead of original test will that work for you without using /bin/sh -c '...'? I think it should?

The problem is not with test, it is “&&” use without a being in a shell, it is not working in a unit file given there is no shell.

An even cleaner approach to the systemd unit file would be:

[Unit]
Description=Daemon for quickly looking up Virtualmin servers from procmail
After=network.target

[Service]
Type=forking
PIDFile=/var/webmin/lookup-domain-daemon.pid
ExecStart=/usr/sbin/virtualmin lookup-domain-daemon

[Install]
WantedBy=multi-user.target

that way systemd knows the pid file, can do the same check and kill, without needing to be dependent on a specific “shell” being pressent.

Steven