2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
2012-07-24 09:51:17 +02:00
|
|
|
let
|
|
|
|
fprotUser = "fprot";
|
|
|
|
stateDir = "/var/lib/fprot";
|
|
|
|
fprotGroup = fprotUser;
|
|
|
|
cfg = config.services.fprot;
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.fprot = {
|
|
|
|
updater = {
|
2014-04-09 00:17:16 +02:00
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable automatic F-Prot virus definitions database updates.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
productData = mkOption {
|
|
|
|
description = ''
|
|
|
|
product.data file. Defaults to the one supplied with installation package.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
frequency = mkOption {
|
|
|
|
default = 30;
|
|
|
|
description = ''
|
|
|
|
Update virus definitions every X minutes.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
licenseKeyfile = mkOption {
|
|
|
|
description = ''
|
|
|
|
License keyfile. Defaults to the one supplied with installation package.
|
|
|
|
'';
|
|
|
|
};
|
2012-07-24 09:51:17 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.updater.enable {
|
2014-04-09 00:09:31 +02:00
|
|
|
|
2014-04-09 00:17:16 +02:00
|
|
|
services.fprot.updater.productData = mkDefault "${pkgs.fprot}/opt/f-prot/product.data";
|
|
|
|
services.fprot.updater.licenseKeyfile = mkDefault "${pkgs.fprot}/opt/f-prot/license.key";
|
2014-04-09 00:09:31 +02:00
|
|
|
|
2012-07-24 09:51:17 +02:00
|
|
|
environment.systemPackages = [ pkgs.fprot ];
|
|
|
|
environment.etc = singleton {
|
|
|
|
source = "${pkgs.fprot}/opt/f-prot/f-prot.conf";
|
|
|
|
target = "f-prot.conf";
|
|
|
|
};
|
|
|
|
|
|
|
|
users.extraUsers = singleton
|
|
|
|
{ name = fprotUser;
|
|
|
|
uid = config.ids.uids.fprot;
|
|
|
|
description = "F-Prot daemon user";
|
|
|
|
home = stateDir;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.extraGroups = singleton
|
|
|
|
{ name = fprotGroup;
|
|
|
|
gid = config.ids.gids.fprot;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.cron.systemCronJobs = [ "*/${toString cfg.updater.frequency} * * * * root start fprot-updater" ];
|
|
|
|
|
|
|
|
jobs = {
|
|
|
|
fprot_updater = {
|
2014-04-09 00:17:16 +02:00
|
|
|
name = "fprot-updater";
|
|
|
|
task = true;
|
2012-07-24 09:51:17 +02:00
|
|
|
|
2014-04-09 00:17:16 +02:00
|
|
|
# have to copy fpupdate executable because it insists on storing the virus database in the same dir
|
2012-07-24 09:51:17 +02:00
|
|
|
preStart = ''
|
|
|
|
mkdir -m 0755 -p ${stateDir}
|
|
|
|
chown ${fprotUser}:${fprotGroup} ${stateDir}
|
2014-04-09 00:17:16 +02:00
|
|
|
cp ${pkgs.fprot}/opt/f-prot/fpupdate ${stateDir}
|
|
|
|
ln -sf ${cfg.updater.productData} ${stateDir}/product.data
|
2012-07-24 09:51:17 +02:00
|
|
|
'';
|
2014-04-09 00:17:16 +02:00
|
|
|
#setuid = fprotUser;
|
|
|
|
#setgid = fprotGroup;
|
2012-07-24 09:51:17 +02:00
|
|
|
exec = "/var/lib/fprot/fpupdate --keyfile ${cfg.updater.licenseKeyfile}";
|
2014-04-09 00:17:16 +02:00
|
|
|
};
|
2012-07-24 09:51:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-04-09 00:17:16 +02:00
|
|
|
}
|