mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
parent
5f76c245b0
commit
ca2e5f2a01
5 changed files with 20 additions and 4 deletions
|
@ -47,6 +47,11 @@ Then reload the configuration.
|
|||
> [`global-config`](../../global-config.rsc) (the one without `-overlay`) to
|
||||
> your local `global-config-overlay` and modify it to your specific needs.
|
||||
|
||||
Using a paid account or running a server on-premises allows to add additional
|
||||
basic authentication. Configure `NtfyServerUser` and `NtfyServerPass` for this.
|
||||
Even authentication via access token is possible, adding it as password with
|
||||
a blank username.
|
||||
|
||||
Usage and invocation
|
||||
--------------------
|
||||
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
# install the module:
|
||||
# $ScriptInstallUpdate mod/notification-ntfy
|
||||
:global NtfyServer "ntfy.sh";
|
||||
:global NtfyServerUser [];
|
||||
:global NtfyServerPass [];
|
||||
:global NtfyTopic "";
|
||||
|
||||
# It is possible to override e-mail, Telegram, Matrix and Ntfy setting
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
:local ScriptName [ :jobname ];
|
||||
|
||||
# expected configuration version
|
||||
:global ExpectedConfigVersion 126;
|
||||
:global ExpectedConfigVersion 127;
|
||||
|
||||
# global variables not to be changed by user
|
||||
:global GlobalFunctionsReady false;
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
:if ([ :typeof $Message ] = "array" ) do={
|
||||
:do {
|
||||
/tool/fetch check-certificate=yes-without-crl output=none http-method=post \
|
||||
($Message->"url") http-header-field=($Message->"headers") http-data=($Message->"text") as-value;
|
||||
http-header-field=($Message->"headers") http-data=($Message->"text") \
|
||||
($Message->"url") user=($Message->"user") password=($Message->"pass") as-value;
|
||||
:set ($NtfyQueue->$Id);
|
||||
} on-error={
|
||||
$LogPrint debug $0 ("Sending queued Ntfy message failed.");
|
||||
|
@ -62,6 +63,10 @@
|
|||
:global NtfyQueue;
|
||||
:global NtfyServer;
|
||||
:global NtfyServerOverride;
|
||||
:global NtfyServerPass;
|
||||
:global NtfyServerPassOverride;
|
||||
:global NtfyServerUser;
|
||||
:global NtfyServerUserOverride;
|
||||
:global NtfyTopic;
|
||||
:global NtfyTopicOverride;
|
||||
|
||||
|
@ -73,6 +78,8 @@
|
|||
:global UrlEncode;
|
||||
|
||||
:local Server [ $EitherOr ($NtfyServerOverride->($Notification->"origin")) $NtfyServer ];
|
||||
:local User [ $EitherOr ($NtfyServerUserOverride->($Notification->"origin")) $NtfyServerUser ];
|
||||
:local Pass [ $EitherOr ($NtfyServerPassOverride->($Notification->"origin")) $NtfyServerPass ];
|
||||
:local Topic [ $EitherOr ($NtfyTopicOverride->($Notification->"origin")) $NtfyTopic ];
|
||||
|
||||
:if ([ :len $Topic ] = 0) do={
|
||||
|
@ -95,7 +102,7 @@
|
|||
}
|
||||
}
|
||||
/tool/fetch check-certificate=yes-without-crl output=none http-method=post \
|
||||
$Url http-header-field=$Headers http-data=$Text as-value;
|
||||
http-header-field=$Headers http-data=$Text $Url user=$User password=$Pass as-value;
|
||||
} on-error={
|
||||
$LogPrint info $0 ("Failed sending ntfy notification! Queuing...");
|
||||
|
||||
|
@ -105,7 +112,8 @@
|
|||
:set Text ($Text . "\n" . [ $SymbolForNotification "alarm-clock" ] . \
|
||||
"This message was queued since " . [ /system/clock/get date ] . " " . \
|
||||
[ /system/clock/get time ] . " and may be obsolete.");
|
||||
:set ($NtfyQueue->[ :len $NtfyQueue ]) { url=$Url; headers=$Headers; text=$Text };
|
||||
:set ($NtfyQueue->[ :len $NtfyQueue ]) \
|
||||
{ url=$Url; user=$User; pass=$Pass; headers=$Headers; text=$Text };
|
||||
:if ([ :len [ /system/scheduler/find where name="_FlushNtfyQueue" ] ] = 0) do={
|
||||
/system/scheduler/add name="_FlushNtfyQueue" interval=1m start-time=startup \
|
||||
on-event=(":global FlushNtfyQueue; \$FlushNtfyQueue;");
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
124="Added support for links in 'netwatch-notify', these are added below the formatted notification text.";
|
||||
125=("April's Fool! " . [ $SymbolForNotification "smiley-partying-face" ] . "Well, you missed it... - no charge nor fees. (Anyway... Donations are much appreciated, " . [ $SymbolForNotification "smiley-smiling-face" ] . "thanks!)");
|
||||
126="Made 'telegram-chat' capable of handling large command output. Telegram messages still limit the size, so it is truncated now.";
|
||||
127="Added support for authentication to Ntfy notification module.";
|
||||
};
|
||||
|
||||
# Migration steps to be applied on script updates
|
||||
|
|
Loading…
Reference in a new issue