[pmg-devel] [PATCH proxmox-mailgateway 4/4] add initial-freshclam.service to pmg-container
Stoiko Ivanov
s.ivanov at proxmox.com
Fri Dec 27 19:36:41 CET 2019
the proxmox-mailgateway-container metapackage is used to build our
Mailgateway container template with 'dab'. When creating the template
clamav-freshclam gets installed, but does not download the virus-definitions
resulting in 'clamav-daemon' not starting upon first boot of the PMG
container.
By adding a service file which invokes 'freshclam' and blocks until the files
are downloaded, which adds a dependency on itself to clamav-daemon the daemon
starts successfully on the first boot of a container.
Not needed for non-container installations.
Tested by adding and enabling the service file on a freshly created (and never
started) pmg-6.1 container and booting it - clamav was running happily after
the download. After a reboot the service did not run because
of the ConditionPathExistsGlob
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
...gateway-container.initial-freshclam.service | 18 ++++++++++++++++++
...mox-mailgateway-container.lintian-overrides | 1 +
debian/rules | 2 ++
3 files changed, 21 insertions(+)
create mode 100644 debian/proxmox-mailgateway-container.initial-freshclam.service
diff --git a/debian/proxmox-mailgateway-container.initial-freshclam.service b/debian/proxmox-mailgateway-container.initial-freshclam.service
new file mode 100644
index 0000000..58a7ba0
--- /dev/null
+++ b/debian/proxmox-mailgateway-container.initial-freshclam.service
@@ -0,0 +1,18 @@
+[Unit]
+Description=Initial download of ClamAV defintion files
+#inverted to the one in clamav-daemon.service
+ConditionPathExistsGlob=!/var/lib/clamav/main.{c[vl]d,inc}
+ConditionPathExistsGlob=!/var/lib/clamav/daily.{c[vl]d,inc}
+Before=clamav-daemon.service clamav-freshclam.service
+After=network-online.target
+Wants=network-online.target
+
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/bin/freshclam --quiet
+
+[Install]
+WantedBy=multi-user.target clamav-daemon.service clamav-freshclam.service
+
diff --git a/debian/proxmox-mailgateway-container.lintian-overrides b/debian/proxmox-mailgateway-container.lintian-overrides
index d324f05..c85797e 100644
--- a/debian/proxmox-mailgateway-container.lintian-overrides
+++ b/debian/proxmox-mailgateway-container.lintian-overrides
@@ -1 +1,2 @@
proxmox-mailgateway-container: package-installs-apt-keyring etc/apt/trusted.gpg.d/proxmox-ve-release-*
+proxmox-mailgateway-container: systemd-service-file-refers-to-unusual-wantedby-target lib/systemd/system/initial-freshclam.service clamav-*.service
diff --git a/debian/rules b/debian/rules
index 0c06312..d985472 100644
--- a/debian/rules
+++ b/debian/rules
@@ -7,3 +7,5 @@
%:
dh $@
+override_dh_installsystemd:
+ dh_installsystemd --no-start --name=initial-freshclam
--
2.20.1
More information about the pmg-devel
mailing list