add ring webhook

This commit is contained in:
Ingolf Wagner 2023-01-31 13:53:32 +01:00
parent 5297e7daab
commit d16ac26712
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
4 changed files with 44 additions and 4 deletions

View file

@ -936,11 +936,11 @@
"secrets": { "secrets": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1674110639, "lastModified": 1675168228,
"narHash": "sha256-IpvJcMtRxcUM4gk8Ha0yKsIJs7Dmo+r9XBb8wUM2sDo=", "narHash": "sha256-n2SBJNQxdWZhnqQwTZS2QDCiPDyBPHHUslGTEpAYCTk=",
"ref": "main", "ref": "main",
"rev": "ef5f10f16f670e26c950bacf95d3d0ec90f0a371", "rev": "ca6040e71ff71e905d896bdbdf8f9c74930ecc78",
"revCount": 40, "revCount": 41,
"type": "git", "type": "git",
"url": "ssh://gitea@git.ingolf-wagner.de/palo/nixos-secrets.git" "url": "ssh://gitea@git.ingolf-wagner.de/palo/nixos-secrets.git"
}, },

View file

@ -67,5 +67,7 @@
# todo move to some place else # todo move to some place else
home-manager.users.mailUser.home.stateVersion = "22.11"; home-manager.users.mailUser.home.stateVersion = "22.11";
} }

View file

@ -30,6 +30,7 @@
./wireguard.nix ./wireguard.nix
./jellyfin.nix ./jellyfin.nix
#./webhook-ring.nix
#../../system/server #../../system/server

View file

@ -0,0 +1,37 @@
{ config, pkgs, ... }:
{
sops.secrets.ringPushover = {
owner = config.services.webhook.user;
};
services.webhook = {
enable = true;
hooks = {
ring = {
execute-command =
let
script = pkgs.writers.writeBash "ring-script" ''
. ${config.sops.secrets.ringPushover.path}
${pkgs.curl}/bin/curl -s \
--form-string "token=$API_KEY" \
--form-string "user=$USER_KEY" \
--form-string "title=Klingeling" \
--form-string "message=Jemand an der Tür" \
https://api.pushover.net/1/messages.json
'';
in
toString script;
response-message = "It's ringing";
};
};
};
services.nginx.virtualHosts."ring.ingolf-wagner.de" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString config.services.webhook.port}/${config.services.webhook.urlPrefix}/ring";
};
};
}