[2/2] clamav: Add scriptlets to handle systemd service files.

Message ID 20230212152013.386417-2-stefan.schantl@ipfire.org
State Accepted
Commit e2849e2653853f91b86af4fc0414019e0273fbd3
Headers
Series [1/2] clamav: Proper create users and groups during package installation. |

Commit Message

Stefan Schantl Feb. 12, 2023, 3:20 p.m. UTC
  Fixes #11603.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 clamav/clamav.nm | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
  

Patch

diff --git a/clamav/clamav.nm b/clamav/clamav.nm
index 14765e000..f941bc6b9 100644
--- a/clamav/clamav.nm
+++ b/clamav/clamav.nm
@@ -82,9 +82,42 @@  packages
 			%{name}-libs = %{thisver}
 		end
 
+		configfiles
+			%{sysconfdir}/clamd.conf
+			%{sysconfdir}/freshclam.conf
+		end
+
+		prerequires
+			systemd-units
+		end
+
 		script prein
 			%{create_users}
 		end
+
+		script postin
+			systemctl daemon-reload >/dev/null 2>&1 || :
+			systemctl enable clamav-freshclam.service >/dev/null 2>&1 || :
+			systemctl enable clamav-daemon.service >/dev/null 2>&1 || :
+		end
+
+		script preun
+			systemctl --no-reload disable clamav-freshclam.service >/dev/null 2>&1 || :
+			systemctl --no-reload disable clamav-daemon.service >/dev/null 2>&1 ||:
+
+			systemctl stop clamav-freshclam.service.service >/dev/null 2>&1 || :
+			systemctl stop clamav-daemon.service >/dev/null 2>&1 || :
+		end
+
+		script postun
+			systemctl daemon-reload >/dev/null 2>&1 || :
+		end
+
+		script postup
+			systemctl daemon-reload >/dev/null 2>&1 || :
+			systemctl try-restart clamav-freshclam.service >/dev/null 2>&1 || :
+			systemctl try-restart clamav-daemon.service >/dev/null 2>&1 || :
+		end
 	end
 
 	package %{name}-libs