CentOS support.

This commit is contained in:
Antoine Nguyen
2016-05-31 12:41:50 +02:00
parent 5c32d7d535
commit 451c3b4695
24 changed files with 1184 additions and 112 deletions

View File

@@ -1,5 +1,6 @@
"""ClamAV related tools."""
from .. import package
from .. import utils
from .. import system
@@ -12,19 +13,55 @@ class Clamav(base.Installer):
appname = "clamav"
daemon_name = "clamav-daemon"
packages = ["clamav-daemon"]
packages = {
"deb": ["clamav-daemon"],
"rpm": [
"clamav", "clamav-update", "clamav-server", "clamav-server-systemd"
],
}
def get_daemon_name(self):
"""Return appropriate daemon name."""
if package.backend.FORMAT == "rpm":
return "clamd@amavisd"
return "clamav-daemon"
@property
def config_dir(self):
"""Return appropriate config dir."""
if package.backend.FORMAT == "rpm":
return "/etc"
return ""
def get_config_files(self):
"""Return appropriate config files."""
if package.backend.FORMAT == "rpm":
return ["sysconfig/clamd.amavisd", "tmpfiles.d/clamd.amavisd.conf"]
return []
def post_run(self):
"""Additional tasks."""
user = self.config.get(self.appname, "user")
system.add_user_to_group(
user, self.config.get("amavis", "user")
)
pattern = (
"s/^AllowSupplementaryGroups false/"
"AllowSupplementaryGroups true/")
utils.exec_cmd(
"perl -pi -e '{}' /etc/clamav/clamd.conf".format(pattern))
if package.backend.FORMAT == "deb":
user = self.config.get(self.appname, "user")
system.add_user_to_group(
user, self.config.get("amavis", "user")
)
pattern = (
"s/^AllowSupplementaryGroups false/"
"AllowSupplementaryGroups true/")
utils.exec_cmd(
"perl -pi -e '{}' /etc/clamav/clamd.conf".format(pattern))
else:
user = "clamupdate"
utils.exec_cmd(
"perl -pi -e 's/^Example/#Example/' /etc/freshclam.conf")
utils.exec_cmd(
"""cat <<EOM >> /usr/lib/systemd/system/clamd@.service
[Install]
WantedBy=multi-user.target
EOM
""")
if utils.dist_name == "ubuntu":
# Stop freshclam daemon to allow manual download
utils.exec_cmd("service clamav-freshclam stop")