mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2024-05-11 05:55:19 +00:00
@ -47,6 +47,11 @@ Then reload the configuration.
|
|||||||
> [`global-config`](../../global-config.rsc) (the one without `-overlay`) to
|
> [`global-config`](../../global-config.rsc) (the one without `-overlay`) to
|
||||||
> your local `global-config-overlay` and modify it to your specific needs.
|
> 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
|
Usage and invocation
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
@ -56,6 +56,8 @@
|
|||||||
# install the module:
|
# install the module:
|
||||||
# $ScriptInstallUpdate mod/notification-ntfy
|
# $ScriptInstallUpdate mod/notification-ntfy
|
||||||
:global NtfyServer "ntfy.sh";
|
:global NtfyServer "ntfy.sh";
|
||||||
|
:global NtfyServerUser [];
|
||||||
|
:global NtfyServerPass [];
|
||||||
:global NtfyTopic "";
|
:global NtfyTopic "";
|
||||||
|
|
||||||
# It is possible to override e-mail, Telegram, Matrix and Ntfy setting
|
# It is possible to override e-mail, Telegram, Matrix and Ntfy setting
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
:local ScriptName [ :jobname ];
|
:local ScriptName [ :jobname ];
|
||||||
|
|
||||||
# expected configuration version
|
# expected configuration version
|
||||||
:global ExpectedConfigVersion 126;
|
:global ExpectedConfigVersion 127;
|
||||||
|
|
||||||
# global variables not to be changed by user
|
# global variables not to be changed by user
|
||||||
:global GlobalFunctionsReady false;
|
:global GlobalFunctionsReady false;
|
||||||
|
@ -38,7 +38,8 @@
|
|||||||
:if ([ :typeof $Message ] = "array" ) do={
|
:if ([ :typeof $Message ] = "array" ) do={
|
||||||
:do {
|
:do {
|
||||||
/tool/fetch check-certificate=yes-without-crl output=none http-method=post \
|
/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);
|
:set ($NtfyQueue->$Id);
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrint debug $0 ("Sending queued Ntfy message failed.");
|
$LogPrint debug $0 ("Sending queued Ntfy message failed.");
|
||||||
@ -62,6 +63,10 @@
|
|||||||
:global NtfyQueue;
|
:global NtfyQueue;
|
||||||
:global NtfyServer;
|
:global NtfyServer;
|
||||||
:global NtfyServerOverride;
|
:global NtfyServerOverride;
|
||||||
|
:global NtfyServerPass;
|
||||||
|
:global NtfyServerPassOverride;
|
||||||
|
:global NtfyServerUser;
|
||||||
|
:global NtfyServerUserOverride;
|
||||||
:global NtfyTopic;
|
:global NtfyTopic;
|
||||||
:global NtfyTopicOverride;
|
:global NtfyTopicOverride;
|
||||||
|
|
||||||
@ -73,6 +78,8 @@
|
|||||||
:global UrlEncode;
|
:global UrlEncode;
|
||||||
|
|
||||||
:local Server [ $EitherOr ($NtfyServerOverride->($Notification->"origin")) $NtfyServer ];
|
: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 ];
|
:local Topic [ $EitherOr ($NtfyTopicOverride->($Notification->"origin")) $NtfyTopic ];
|
||||||
|
|
||||||
:if ([ :len $Topic ] = 0) do={
|
:if ([ :len $Topic ] = 0) do={
|
||||||
@ -95,7 +102,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/tool/fetch check-certificate=yes-without-crl output=none http-method=post \
|
/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={
|
} on-error={
|
||||||
$LogPrint info $0 ("Failed sending ntfy notification! Queuing...");
|
$LogPrint info $0 ("Failed sending ntfy notification! Queuing...");
|
||||||
|
|
||||||
@ -105,7 +112,8 @@
|
|||||||
:set Text ($Text . "\n" . [ $SymbolForNotification "alarm-clock" ] . \
|
:set Text ($Text . "\n" . [ $SymbolForNotification "alarm-clock" ] . \
|
||||||
"This message was queued since " . [ /system/clock/get date ] . " " . \
|
"This message was queued since " . [ /system/clock/get date ] . " " . \
|
||||||
[ /system/clock/get time ] . " and may be obsolete.");
|
[ /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={
|
:if ([ :len [ /system/scheduler/find where name="_FlushNtfyQueue" ] ] = 0) do={
|
||||||
/system/scheduler/add name="_FlushNtfyQueue" interval=1m start-time=startup \
|
/system/scheduler/add name="_FlushNtfyQueue" interval=1m start-time=startup \
|
||||||
on-event=(":global FlushNtfyQueue; \$FlushNtfyQueue;");
|
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.";
|
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!)");
|
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.";
|
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
|
# Migration steps to be applied on script updates
|
||||||
|
Reference in New Issue
Block a user