summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2019-07-09 20:52:23 +0200
committertv <tv@krebsco.de>2019-07-09 20:52:23 +0200
commit421a97927b24e69840d34a98eaf7673fea2d4c3c (patch)
tree2800d00396e7c533209662eff503a9a2e6eaa11f
parent03aea512d8be3b38be78ab99c6f0dd9400e71d97 (diff)
parentb9ab8446354378719dfa546108d4e96f7852d3d7 (diff)
Merge remote-tracking branches 'prism/master' and 'kmein/master'
-rw-r--r--krebs/3modules/urlwatch.nix44
1 files changed, 31 insertions, 13 deletions
diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix
index 0cec1a2d3..3c9ff7709 100644
--- a/krebs/3modules/urlwatch.nix
+++ b/krebs/3modules/urlwatch.nix
@@ -17,6 +17,8 @@ let
api = {
enable = mkEnableOption "krebs.urlwatch";
+ customSendmail.enable = mkEnableOption "krebs.urlwatch.customSendmail";
+
dataDir = mkOption {
type = types.str;
default = "/var/lib/urlwatch";
@@ -54,6 +56,15 @@ let
The format is described in systemd.time(7), CALENDAR EVENTS.
'';
};
+ telegram = {
+ enable = mkEnableOption "krebs.urlwatch.telegram" // { default = false; };
+ botToken = mkOption {
+ type = types.str;
+ };
+ chatId = mkOption {
+ type = types.listOf types.str;
+ };
+ };
urls = mkOption {
type = with types; listOf (either str subtypes.job);
default = [];
@@ -110,6 +121,11 @@ let
color = true;
enabled = true;
};
+ ${if cfg.telegram.enable then "telegram" else null} = {
+ enabled = cfg.telegram.enable;
+ bot_token = cfg.telegram.botToken;
+ chat_id = cfg.telegram.chatId;
+ };
text = {
details = true;
footer = true;
@@ -158,19 +174,21 @@ let
--urls=${shell.escape urlsFile} \
> changes || :
- if test -s changes; then
- {
- echo Date: $(date -R)
- echo From: ${shell.escape cfg.from}
- echo Subject: $(
- sed -n 's/^\(CHANGED\|ERROR\|NEW\): //p' changes \
- | tr '\n' ' '
- )
- echo To: ${shell.escape cfg.mailto}
- echo
- cat changes
- } | /run/wrappers/bin/sendmail -t
- fi
+ ${optionalString cfg.customSendmail.enable /* sh */ ''
+ if test -s changes; then
+ {
+ echo Date: $(date -R)
+ echo From: ${shell.escape cfg.from}
+ echo Subject: $(
+ sed -n 's/^\(CHANGED\|ERROR\|NEW\): //p' changes \
+ | tr '\n' ' '
+ )
+ echo To: ${shell.escape cfg.mailto}
+ echo
+ cat changes
+ } | /run/wrappers/bin/sendmail -t
+ fi
+ ''}
'';
};
};