phpipam: add auto_remove script

This commit is contained in:
Sean Buckley 2021-07-12 14:37:57 -04:00
parent 530fadc247
commit 474b9d3c15
2 changed files with 21 additions and 17 deletions

View file

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1625601352, "lastModified": 1625919529,
"narHash": "sha256-yCvbAC+gadcmW94KvXbTLWC5erkcKClQWX3G8k5O7u0=", "narHash": "sha256-Epn7JRegnKN81hQh4hGx1FOwfp3fBxDCIuSZDgqaBQ4=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "9d1350d9d56411b685ff3de5839ed6728b1bf808", "rev": "cf59fbd539681f5ec2f4a82cf77aae7ab827a03f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -23,11 +23,11 @@
}, },
"unstable": { "unstable": {
"locked": { "locked": {
"lastModified": 1625533413, "lastModified": 1625874246,
"narHash": "sha256-D4Dp2qDmY3Y9/Mqxsha/18F0RsH3hPiHafG4bvTz2V4=", "narHash": "sha256-7cGgcysIXz/j/lRpJn7cNJjf0+k7sQ5EuGn62252Svw=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "036dc0c709650e0c833822307af801f576d67273", "rev": "45fc7d4a35c5343e58541a7847f6415654ccbb37",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -21,6 +21,12 @@ let
''; '';
}; };
cronScripts = {
phpipam_ping = "exec ${pkgs.php}/bin/php ${phpipamHtdocs}/functions/scripts/pingCheck.php";
phpipam_remove_offline = "exec ${pkgs.php}/bin/php ${phpipamHtdocs}/functions/scripts/remove_offline_addresses.php";
phpipam_discovery = "exec ${pkgs.php}/bin/php ${phpipamHtdocs}/functions/scripts/discoveryCheck.php";
};
in in
{ {
options.sconfig.phpipam = { options.sconfig.phpipam = {
@ -51,20 +57,18 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
systemd.services = { systemd.services = builtins.mapAttrs
phpipam_ping = { (_: script: {
script = "exec ${pkgs.php}/bin/php ${phpipamHtdocs}/functions/scripts/pingCheck.php"; inherit script;
environment.IPAM_DATABASE_USER = "nginx"; environment.IPAM_DATABASE_USER = "nginx";
serviceConfig.User = "nginx"; serviceConfig.User = "nginx";
startAt = "*:0/15"; startAt = "*:0/15";
}; })
phpipam_discovery = { cronScripts;
script = "exec ${pkgs.php}/bin/php ${phpipamHtdocs}/functions/scripts/discoveryCheck.php";
environment.IPAM_DATABASE_USER = "nginx"; systemd.timers = builtins.mapAttrs
serviceConfig.User = "nginx"; (_: _: { timerConfig.RandomizedDelaySec = 600; })
startAt = "*:0/15"; cronScripts;
};
};
services = { services = {