mirror of
https://github.com/kmein/niveum
synced 2026-03-16 10:11:08 +01:00
feat(panoptikon): setup in different service
This commit is contained in:
@@ -71,44 +71,60 @@
|
|||||||
})
|
})
|
||||||
cfg.watchers;
|
cfg.watchers;
|
||||||
|
|
||||||
systemd.services = lib.attrsets.mapAttrs' (watcherName: watcherOptions:
|
systemd.services =
|
||||||
lib.nameValuePair "panoptikon-${watcherName}" {
|
{
|
||||||
enable = true;
|
setup-panoptikon = {
|
||||||
startAt = watcherOptions.frequency;
|
enable = true;
|
||||||
serviceConfig = {
|
wantedBy = ["multi-user.target"];
|
||||||
Type = "oneshot";
|
serviceConfig = {
|
||||||
User = "panoptikon";
|
Type = "oneshot";
|
||||||
Group = "panoptikon";
|
User = "panoptikon";
|
||||||
WorkingDirectory = "/var/lib/panoptikon";
|
Group = "panoptikon";
|
||||||
RestartSec = "60";
|
WorkingDirectory = "/var/lib/panoptikon";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
${pkgs.git}/bin/git init --quiet
|
||||||
|
${pkgs.git}/bin/git config user.email "panoptikon@${config.networking.hostName}"
|
||||||
|
${pkgs.git}/bin/git config user.name Panoptikon
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
unitConfig = {
|
}
|
||||||
StartLimitIntervalSec = "300";
|
// lib.attrsets.mapAttrs' (watcherName: watcherOptions:
|
||||||
StartLimitBurst = "5";
|
lib.nameValuePair "panoptikon-${watcherName}" {
|
||||||
};
|
enable = true;
|
||||||
environment.PANOPTIKON_WATCHER = watcherName;
|
after = ["setup-panoptikon.service"];
|
||||||
wants = ["network-online.target"];
|
startAt = watcherOptions.frequency;
|
||||||
script = ''
|
serviceConfig = {
|
||||||
set -efux
|
Type = "oneshot";
|
||||||
|
User = "panoptikon";
|
||||||
|
Group = "panoptikon";
|
||||||
|
WorkingDirectory = "/var/lib/panoptikon";
|
||||||
|
RestartSec = "60";
|
||||||
|
Restart = "on-failure";
|
||||||
|
};
|
||||||
|
unitConfig = {
|
||||||
|
StartLimitIntervalSec = "300";
|
||||||
|
StartLimitBurst = "5";
|
||||||
|
};
|
||||||
|
environment.PANOPTIKON_WATCHER = watcherName;
|
||||||
|
wants = ["network-online.target"];
|
||||||
|
script = ''
|
||||||
|
set -efux
|
||||||
|
|
||||||
${pkgs.git}/bin/git init --quiet
|
${watcherOptions.script} > ${watcherName}
|
||||||
${pkgs.git}/bin/git config user.email "panoptikon@${config.networking.hostName}"
|
${pkgs.git}/bin/git add ${watcherName}
|
||||||
${pkgs.git}/bin/git config user.name Panoptikon
|
${pkgs.git}/bin/git commit --message "$(${pkgs.coreutils}/bin/date -Is)" || :
|
||||||
|
|
||||||
${watcherOptions.script} > ${watcherName}
|
if [ -n "$(${pkgs.git}/bin/git diff HEAD^ -- ${watcherName})" ]; then
|
||||||
${pkgs.git}/bin/git add ${watcherName}
|
${lib.strings.concatMapStringsSep "\n" (reporter: ''
|
||||||
${pkgs.git}/bin/git commit --message "$(${pkgs.coreutils}/bin/date -Is)" || :
|
${pkgs.git}/bin/git diff HEAD^ -- ${watcherName} | ${reporter}
|
||||||
|
'')
|
||||||
if [ -n "$(${pkgs.git}/bin/git diff HEAD^ -- ${watcherName})" ]; then
|
watcherOptions.reporters}
|
||||||
${lib.strings.concatMapStringsSep "\n" (reporter: ''
|
:
|
||||||
${pkgs.git}/bin/git diff HEAD^ -- ${watcherName} | ${reporter}
|
fi
|
||||||
'')
|
'';
|
||||||
watcherOptions.reporters}
|
})
|
||||||
:
|
cfg.watchers;
|
||||||
fi
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
cfg.watchers;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user