aboutsummaryrefslogtreecommitdiff
path: root/modules/nessus-daemon/module.nix
blob: f33cf0c6636ff659138bbf493da987ec869c39d6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{ config, lib, pkgs, ... }:
with lib;
let
  cfg = config.services.nessus-agent;
  nessus-agent-fhs = (pkgs.callPackage ./fhs.nix {});
in {
  options.services.nessus-agent = {
    enable = mkEnableOption "nessus agent";
    openFirewall = mkEnableOption "open firewall for nessus";
    port = mkOption { type = types.int; default = 8834; };
  };

  config = mkIf cfg.enable {
    systemd.tmpfiles.rules = [
      "d /opt/nessus_agent 0755 root root -"
    ];

    networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];

    systemd.services.nessus-agent = {
      description = "Tenable Nessus Agent Service";
      wantedBy = [ "multi-user.target" ];
      after = [ "network.target" ];
      path = [ pkgs.coreutils ];
      serviceConfig = {
        Type = "simple";
        Restart = "on-abort";
        User = "root";
        Group = "root";
        PIDFile = "/opt/nessus_agent/var/nessus/nessus-service.pid";
        ExecStart = "${nessus-agent-fhs}/bin/nessus-agent-fhs /opt/nessus_agent/sbin/nessus-service -q --port ${toString cfg.port}";
        ExecReload = "/usr/bin/pkill nessusd";
        EnvironmentFile = "-/etc/sysconfig/nessusagent";
        PrivateNetwork = false;
      };
    };
  };
}