systemd / active (exited)

Colin Watson cjwatson at ubuntu.com
Sat Aug 31 10:57:21 UTC 2019


On Fri, Aug 30, 2019 at 08:29:09AM -0000, Helmut Schneider wrote:
> systemd is a book with 7 seals for me, who ever had the idea completely
> lost me. It starts with I have not idea how to use variables and start
> clamd chrooted:

The vast majority of the complexity here comes from you using systemd's
compatibility mode with SysV init scripts.  I suspect that
systemd-sysv-generator is getting a bit confused by the multiple forks
that are going to be involved in the chroot setup here, and thus loses
track of the relevant process.  (Managing to keep track of and supervise
most services started by /etc/init.d/ scripts without modifications,
going beyond what sysvinit ever did, is technically quite impressive,
but it's not without limits.)

I'd be strongly inclined to write a native systemd service file for this
instead, which would be much easier to understand and debug.  Something
like this, based on the existing clamav-daemon.service (you could even
use "systemctl edit" to extend the existing clamav-daemon.service by
adding the User, Group, and RootDirectory directives, rather than having
to add a whole replacement service):


[Unit]
Description=Clam AntiVirus userspace daemon
Documentation=man:clamd(8) man:clamd.conf(5) https://www.clamav.net/documents/
# Check for database existence
ConditionPathExistsGlob=/var/lib/clamav/main.{c[vl]d,inc}
ConditionPathExistsGlob=/var/lib/clamav/daily.{c[vl]d,inc}

[Service]
User=amavis
Group=amavis
RootDirectory=/var/amavis
ExecStart=/usr/sbin/clamd --foreground=true
# Reload the database
ExecReload=/bin/kill -USR2 $MAINPID
StandardOutput=syslog

[Install]
WantedBy=multi-user.target


(This may require some further tweaking: in particular, I'm not sure
whether you need to adjust the ConditionPathExistsGlob directives, or
whether you need to add a --config-file option somewhere, or what.  But
if you're starting from somewhere like this rather than from an init
script, then "systemctl status" output will be much more likely to make
sense, and you'll have less shell script verbiage to wade through.)

-- 
Colin Watson                                       [cjwatson at ubuntu.com]




More information about the ubuntu-users mailing list