From 7448d3431fcfc05f9b7991e337b02083300a99db Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 1 Nov 2022 22:43:25 +0100 Subject: ... --- modules/zfssnap/default.nix | 18 ++++++++++++++++-- modules/zfssnap/zfssnap/zfssnap/__main__.py | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'modules/zfssnap') diff --git a/modules/zfssnap/default.nix b/modules/zfssnap/default.nix index f46cd510..f6f32852 100644 --- a/modules/zfssnap/default.nix +++ b/modules/zfssnap/default.nix @@ -48,6 +48,20 @@ in { type = types.str; default = "*-*-* *:00/5:00"; }; + + verbosity = mkOption { + type = types.int; + default = 2; + }; + + extraPruneArgs = mkOption { + type = with types; listOf str; + default = []; + }; + extraAutosnapArgs = mkOption { + type = with types; listOf str; + default = []; + }; }; }; @@ -59,7 +73,7 @@ in { before = [ "zfssnap-prune.service" ]; serviceConfig = { Type = "oneshot"; - ExecStart = "${zfssnap}/bin/zfssnap -vv"; + ExecStart = "${zfssnap}/bin/zfssnap --verbosity=${toString cfg.verbosity} autosnap ${escapeShellArgs cfg.extraAutosnapArgs}"; LogRateLimitIntervalSec = 0; }; @@ -72,7 +86,7 @@ in { ExecStart = let mkSectionName = name: strings.escape [ "[" "]" ] (strings.toUpper name); zfssnapConfig = generators.toINI { inherit mkSectionName; } cfg.config; - in "${zfssnap}/bin/zfssnap -vv prune --config=${pkgs.writeText "zfssnap.ini" zfssnapConfig}"; + in "${zfssnap}/bin/zfssnap --verbosity=${toString cfg.verbosity} prune --config=${pkgs.writeText "zfssnap.ini" zfssnapConfig} ${escapeShellArgs cfg.extraPruneArgs}"; LogRateLimitIntervalSec = 0; }; diff --git a/modules/zfssnap/zfssnap/zfssnap/__main__.py b/modules/zfssnap/zfssnap/zfssnap/__main__.py index 9d07401b..59478c71 100644 --- a/modules/zfssnap/zfssnap/zfssnap/__main__.py +++ b/modules/zfssnap/zfssnap/zfssnap/__main__.py @@ -375,10 +375,13 @@ def main(): sys.excepthook = log_exceptions parser = argparse.ArgumentParser(prog='zfssnap') + parser.add_argument('--verbosity', dest='log_level', action='append') parser.add_argument('--verbose', '-v', dest='log_level', action='append_const', const=-1) parser.add_argument('--quiet', '-q', dest='log_level', action='append_const', const=1) subparsers = parser.add_subparsers() parser.set_defaults(cmd=autosnap) + autosnap_parser = subparsers.add_parser('autosnap') + autosnap_parser.set_defaults(cmd=autosnap) rename_parser = subparsers.add_parser('rename') rename_parser.add_argument('snapshots', nargs='+') rename_parser.add_argument('--destroy', action='store_true', default=False) -- cgit v1.2.3