forked from DGNum/infrastructure
Tom Hubrecht
88d9b8c3e3
Signed-off-by: Tom Hubrecht <tom.hubrecht@dgnum.eu> Acked-by: Ryan Lahfa <ryan.lahfa@dgnum.eu> Acked-by: Maurice Debray <maurice.debray@dgnum.eu> Acked-by: Lubin Bailly <lubin.bailly@dgnum.eu> Acked-by: Jean-Marc Gailis <jean-marc.gailis@dgnum.eu> as the legal authority, at the time of writing, in DGNum. Acked-by: Elias Coppens <elias.coppens@dgnum.eu> as a member, at the time of writing, of the DGNum executive counsel.
60 lines
1.3 KiB
Nix
60 lines
1.3 KiB
Nix
# SPDX-FileCopyrightText: 2024 Lubin Bailly <lubin.bailly@dgnum.eu>
|
|
#
|
|
# SPDX-License-Identifier: EUPL-1.2
|
|
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
{
|
|
services = {
|
|
ulogd = {
|
|
enable = true;
|
|
logLevel = 5;
|
|
settings = {
|
|
global = {
|
|
logfile = "/var/log/ulogd.log";
|
|
stack = [ "ct1:NFCT,ip2str1:IP2STR,pgsql1:PGSQL" ];
|
|
};
|
|
ct1 = { };
|
|
pgsql1 = {
|
|
db = "ulogd";
|
|
user = "ulogd";
|
|
table = "ulog2_ct";
|
|
procedure = "INSERT_CT";
|
|
};
|
|
};
|
|
};
|
|
postgresql = {
|
|
enable = true;
|
|
identMap = ''
|
|
ulogd-map root ulogd
|
|
'';
|
|
authentication = ''
|
|
local ulogd ulogd peer map=ulogd-map
|
|
'';
|
|
|
|
ensureUsers = [
|
|
{
|
|
name = "ulogd";
|
|
ensureDBOwnership = true;
|
|
}
|
|
];
|
|
ensureDatabases = [ "ulogd" ];
|
|
};
|
|
};
|
|
systemd.services.ulogd = {
|
|
serviceConfig.StateDirectory = "ulogd";
|
|
requires = [ "postgresql.service" ];
|
|
after = [ "postgresql.service" ];
|
|
path = [ config.services.postgresql.package ];
|
|
preStart = lib.mkAfter ''
|
|
if ! test -e "/var/lib/ulogd/.initialized"; then
|
|
psql -f "${pkgs.ulogd.doc}/share/doc/ulogd-pgsql/pgsql-ulogd2.sql" -d ulogd -U ulogd
|
|
touch "/var/lib/ulogd/.initialized"
|
|
fi
|
|
'';
|
|
};
|
|
}
|