reformat, fix load env vars, update README
This commit is contained in:
parent
9a76430181
commit
e658def798
3 changed files with 159 additions and 126 deletions
23
README.md
23
README.md
|
|
@ -44,7 +44,28 @@ Add this to your `configuration.nix` file
|
|||
|
||||
```nix
|
||||
environment.etc."eintopf-radar-sync-secrets.yml".text = ''
|
||||
EINTOPF_AUTHORIZATION_TOKEN=foobar23
|
||||
accounts:
|
||||
- name: Sales
|
||||
imap_server: mail.example.com
|
||||
imap_port: 993
|
||||
username: sales@example.com
|
||||
password: secret
|
||||
|
||||
- name: Support
|
||||
imap_server: mail.example.com
|
||||
imap_port: 993
|
||||
username: support@example.com
|
||||
password: secret
|
||||
|
||||
mail:
|
||||
smtp_server: mail.example.com
|
||||
smtp_port: 587
|
||||
smtp_username: monitoring@example.com
|
||||
smtp_password: secret
|
||||
from_address: monitoring@example.com
|
||||
recipients:
|
||||
- admin1@example.com
|
||||
- admin2@example.com
|
||||
'';
|
||||
|
||||
services.mail-quota-warning = {
|
||||
|
|
|
|||
|
|
@ -263,8 +263,8 @@ def main():
|
|||
args = parse_args()
|
||||
config = load_config(args.config)
|
||||
state = load_state()
|
||||
interval_days = config.get("check_interval_days", 7)
|
||||
threshold = config.get("quota_warning_threshold_percent", 80)
|
||||
interval_days = get_config_value(config, "CHECK_INTERVAL_DAYS", "check_interval_days", 7, int)
|
||||
threshold = get_config_value(config, "QUOTA_WARNING_THRESHOLD_PERCENT", "quota_warning_threshold_percent", 80, int)
|
||||
|
||||
# For thread-safe state updates
|
||||
state_lock = threading.Lock()
|
||||
|
|
|
|||
32
module.nix
32
module.nix
|
|
@ -1,10 +1,15 @@
|
|||
{config, lib, pkgs, ...}:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
|
||||
cfg = config.services.mail-quota-warning;
|
||||
|
||||
in
|
||||
{
|
||||
{
|
||||
|
||||
options = {
|
||||
services.mail-quota-warning = {
|
||||
|
|
@ -39,7 +44,7 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
default = { };
|
||||
description = ''
|
||||
Extra options which should be used by the mailbox quota warning script.
|
||||
'';
|
||||
|
|
@ -82,14 +87,15 @@ in
|
|||
wants = [ "network-online.target" ];
|
||||
environment = {
|
||||
PYTHONUNBUFFERED = "1";
|
||||
} // lib.mapAttrs (_: v: toString v) cfg.settings;
|
||||
}
|
||||
// lib.mapAttrs (_: v: toString v) cfg.settings;
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = lib.getExe pkgs.mail-quota-warning;
|
||||
|
||||
# hardening
|
||||
AmbientCapabilities = "";
|
||||
CapabilityBoundingSet = "" ;
|
||||
CapabilityBoundingSet = "";
|
||||
DevicePolicy = "closed";
|
||||
DynamicUser = true;
|
||||
LockPersonality = true;
|
||||
|
|
@ -109,14 +115,21 @@ in
|
|||
ProtectProc = "invisible";
|
||||
ProtectSystem = "strict";
|
||||
RemoveIPC = true;
|
||||
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
|
||||
RestrictAddressFamilies = [
|
||||
"AF_INET"
|
||||
"AF_INET6"
|
||||
];
|
||||
RestrictNamespaces = true;
|
||||
RestrictRealtime = true;
|
||||
RestrictSUIDSGID = true;
|
||||
SystemCallArchitectures = "native";
|
||||
SystemCallFilter = [ "@system-service" "~@privileged" ];
|
||||
SystemCallFilter = [
|
||||
"@system-service"
|
||||
"~@privileged"
|
||||
];
|
||||
UMask = "0077";
|
||||
} // lib.optionalAttrs (cfg.secretFile != [ ]) {
|
||||
}
|
||||
// lib.optionalAttrs (cfg.secretFile != [ ]) {
|
||||
EnvironmentFile = cfg.secretFile;
|
||||
};
|
||||
};
|
||||
|
|
@ -137,5 +150,4 @@ in
|
|||
maintainers = with lib.maintainers; [ onny ];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue