Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 497756

Summary: mail-filter/amavisd-new: systemd unit
Product: Gentoo Linux Reporter: David Heidelberg (okias) <david>
Component: Current packagesAssignee: Antivirus Team <antivirus>
Status: RESOLVED FIXED    
Severity: normal CC: net-mail+disabled, systemd
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 448882    
Attachments: amavisd.service
amavisd-new.ebuild.patch

Description David Heidelberg (okias) 2014-01-11 03:12:41 UTC
[Unit]
Description=Amavisd Daemon
Wants=postfix.service
Wants=spamassassin.service
After=network.target

[Service]
PIDFile=/run/amavis/pid
ExecStart=/usr/bin/amavisd -c /etc/amavisd/amavisd.conf foreground
ExecReload=/usr/bin/amavisd -c /etc/amavisd/amavisd.conf reload

[Install]
WantedBy=multi-user.target


Reproducible: Always
Comment 1 David Heidelberg (okias) 2014-01-11 03:16:25 UTC
Oops, sorry, this works.

---
[Unit]
Description=Amavisd Daemon
Wants=postfix.service
Wants=spamassassin.service
After=network.target

[Service]
PIDFile=/run/amavis/pid
ExecStart=/usr/sbin/amavisd -c /etc/amavisd.conf foreground
ExecReload=/usr/sbin/amavisd -c /etc/amavisd.conf reload

[Install]
WantedBy=multi-user.target
Comment 2 Pacho Ramos gentoo-dev 2014-01-11 12:59:17 UTC
Why do you need "PIDFile" even running in foreground?
Comment 3 David Heidelberg (okias) 2014-01-11 19:31:00 UTC
@pacho No idea, I just took systemd unit from Arch Linux, not sure why they did it.
Comment 4 Pacho Ramos gentoo-dev 2014-01-11 20:37:52 UTC
Created attachment 367658 [details]
amavisd.service

Please try this one, I have doubts about what list in Wants :/, it supposedly should work with any virtual/mta provider with unit files, also, looks like opensuse is adding Wants=clamd.service (equivalent to current init.d) instead of spamassassin:
http://download.opensuse.org/repositories/openSUSE:/13.1:/Update/standard/src/amavisd-new-2.8.1-2.8.1.src.rpm
Comment 5 David Heidelberg (okias) 2014-01-12 13:25:41 UTC
Wants=clamd.service should be included in case we add mail-filter/amavisd-new-2.8.1[clamd] which will leave this line in systemd file,

otherwise sed -i /clamd/d

I can't test right now (server is running and I can't just change services in this moment). Otherwise, when we got final solution, I'll replace that file and in soon reboot test.
Comment 6 Pacho Ramos gentoo-dev 2014-01-12 13:38:01 UTC
OK, @systemd, any suggestions?
Comment 7 David Heidelberg (okias) 2014-01-12 15:36:33 UTC
Maybe I should create bug report for adding clamd USE to amavisd-new ?
Comment 8 David Heidelberg (okias) 2014-01-26 06:54:19 UTC
File from SuSE. There should be both, clamd and spamassasin depending on USE flags.
=========================
[Unit]
Description=Amavisd-new Virus Scanner interface
Requires=var-run.mount
Wants=nss-lookup.target network.target remote-fs.target time-sync.target
After=var-run.mount nss-lookup.target network.target remote-fs.target time-sync.target
Wants=named.service clamd.service
After=named.service clamd.service
Before=mail-transfer-agent.target

[Service]
Type=forking
PIDFile=/var/spool/amavis/amavisd.pid
ExecStartPre=-/bin/echo 'Starting virus-scanner (amavisd-new):'
EnvironmentFile=-/etc/sysconfig/amavisd
ExecStartPre=/usr/sbin/amavisd-milter.sh start
ExecStart=/usr/sbin/amavisd start
ExecStartPost=
ExecStartPost=
ExecReload=/usr/sbin/amavisd reload
ExecStop=/usr/sbin/amavisd stop
ExecStopPost=/usr/sbin/amavisd-milter.sh stop

[Install]
WantedBy=multi-user.target
Comment 9 David Heidelberg (okias) 2014-02-04 00:43:35 UTC
[Unit]
Description=Amavisd Daemon
Wants=postfix.service
Wants=spamassassin.service
Wants=clamd.service
After=network.target

[Service]
PIDFile=/run/amavis/pid
ExecStart=/usr/sbin/amavisd -c /etc/amavisd.conf foreground
ExecReload=/usr/sbin/amavisd -c /etc/amavisd.conf reload

[Install]
WantedBy=multi-user.target

I'd like to propose at least this, as solution, it works someway, can this be accepted (better than nothing)?
then if ebuild

if !use clamd; then
     sed /Wants=clamd/d "${ED}"/usr/lib/systemd/system/amavisd.service
fi
if !use spamassasin; then
     sed /Wants=spamassassin/d "${ED}"/usr/lib/systemd/system/amavisd.service
fi
Comment 10 David Heidelberg (okias) 2014-02-08 21:12:48 UTC
Is this acceptable? Should I create patches?
Comment 11 Pacho Ramos gentoo-dev 2014-02-15 13:16:24 UTC
+*amavisd-new-2.8.1-r1 (15 Feb 2014)
+
+  15 Feb 2014; Pacho Ramos <pacho@gentoo.org> +amavisd-new-2.8.1-r1.ebuild,
+  +files/amavisd.service:
+  Add unit file (#497756 by David Heidelberger (okias))
+
Comment 12 David Heidelberg (okias) 2014-02-15 13:24:41 UTC
That damn good, I'll retest ASAP!
Comment 13 David Heidelberg (okias) 2014-02-15 14:30:15 UTC
Created attachment 370490 [details, diff]
amavisd-new.ebuild.patch

Well, there is few typos in that commit, here is fix.
Comment 14 Pacho Ramos gentoo-dev 2014-02-15 15:01:01 UTC
I saw this comment here after fixing it ;) Thanks!