Compare commits
73 commits
main
...
change-80-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdb698acbf | ||
|
|
1b3f2620a7 | ||
|
|
a5c233b28c | ||
|
|
5f0a7efe1e | ||
|
|
1b5f261f3d | ||
|
|
58f7782477 | ||
|
|
e49e454381 | ||
|
|
357618a1a5 | ||
|
|
af589df82c | ||
|
|
c84017de2c | ||
|
|
087e7bc3b7 | ||
|
|
2b647bef80 | ||
|
|
0479f59aa4 | ||
|
|
4cda1281f1 | ||
|
|
006e054517 | ||
|
|
d9c4e1e8d5 | ||
|
|
2e8f457109 | ||
|
|
7a714ad182 | ||
|
|
e7481f3ca8 | ||
|
|
f5465d3e34 | ||
|
|
2c2a3013f3 | ||
|
|
82c0e1c44c | ||
|
|
58f5a4fced | ||
|
|
1cddf5590d | ||
|
|
5570258ce8 | ||
|
|
d21cd2271f | ||
|
|
0695c99318 | ||
|
|
fab05ecd7d | ||
|
|
98b08bcbd2 | ||
|
|
ddb181fbc2 | ||
|
|
e25250e27b | ||
|
|
b35e39b0fa | ||
|
|
c5cc72de0e | ||
|
|
6336da6bd7 | ||
|
|
184959bc77 | ||
|
|
bf6c7d27df | ||
|
|
b11a83aac2 | ||
|
|
d0699857c9 | ||
|
|
a7da21e185 | ||
|
|
a45b8d7d8c | ||
|
|
3f6b5595f3 | ||
|
|
82d45eca08 | ||
|
|
fed4757eaa | ||
|
|
9419e34077 | ||
|
|
39871f2221 | ||
|
|
d1c4eb2303 | ||
|
|
10bb0a9f52 | ||
|
|
cd1de8145b | ||
|
|
06bdce1378 | ||
|
|
17b3e04d41 | ||
|
|
798fd7cc86 | ||
|
|
d1c9fe4dce | ||
|
|
5e7735a507 | ||
|
|
5f52e3e3f4 | ||
|
|
2f965630fa | ||
|
|
a9805365d2 | ||
|
|
b60dcb5fad | ||
|
|
3dd3452303 | ||
|
|
943b60bfe3 | ||
|
|
32cc55f7d2 | ||
|
|
c95e816148 | ||
|
|
0c607a8f9c | ||
|
|
c03da561cd | ||
|
|
8d49babb01 | ||
|
|
b2f45c0350 | ||
|
|
52bd08b750 | ||
|
|
221b0409d5 | ||
|
|
0a9d0473f3 | ||
|
|
9024e20c0b | ||
|
|
5363df3568 | ||
|
|
25338ca384 | ||
|
|
ee9818e34d | ||
|
|
7d5c967995 |
|
|
@ -7,12 +7,14 @@ Thanks a lot for your contributions!
|
||||||
|
|
||||||
## Patches
|
## Patches
|
||||||
|
|
||||||
These persons contributed code. See the git history for details!
|
These persons contributed code or documentation. See the git history
|
||||||
|
for details!
|
||||||
|
|
||||||
* [Ben Harris](mailto:mail@bharr.is) (@bharrisau)
|
* [Ben Harris](mailto:mail@bharr.is) (@bharrisau)
|
||||||
* [Daniel Ziegenberg](mailto:daniel@ziegenberg.at) (@ziegenberg)
|
* [Daniel Ziegenberg](mailto:daniel@ziegenberg.at) (@ziegenberg)
|
||||||
* [Michael Gisbers](mailto:michael@gisbers.de) (@mgisbers)
|
* [Michael Gisbers](mailto:michael@gisbers.de) (@mgisbers)
|
||||||
* [netztrip](mailto:dave-tvg@netztrip.de) (@netztrip)
|
* [netztrip](mailto:dave-tvg@netztrip.de) (@netztrip)
|
||||||
|
* [Stefan Müller](mailto:stefan.mueller.83@gmail.com) (@PackElend)
|
||||||
|
|
||||||
## Donations
|
## Donations
|
||||||
|
|
||||||
|
|
@ -22,6 +24,8 @@ Add yourself to the list,
|
||||||
* Abdul Mannan Abbasi
|
* Abdul Mannan Abbasi
|
||||||
* Andrew Cox
|
* Andrew Cox
|
||||||
* Christoph Boss (@Kampfwurst)
|
* Christoph Boss (@Kampfwurst)
|
||||||
|
* Devin Dean (@dd2594gh)
|
||||||
|
* Evaldo Gardenal
|
||||||
* Klaus Michael Rübsam
|
* Klaus Michael Rübsam
|
||||||
* Linux-Schmie.de Michael Gisbers
|
* Linux-Schmie.de Michael Gisbers
|
||||||
* Manuel Kuhn
|
* Manuel Kuhn
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,13 @@ Initial commands
|
||||||
|
|
||||||
[◀ Go back to main README](README.md)
|
[◀ Go back to main README](README.md)
|
||||||
|
|
||||||
These command are inteneded for initial setup. If you are not aware of the
|
> ⚠️ **Warning**: These commands are inteneded for initial setup. If you are
|
||||||
procedure please follow [the long way in detail](README.md#the-long-way-in-detail).
|
> not aware of the procedure please follow
|
||||||
|
> [the long way in detail](README.md#the-long-way-in-detail).
|
||||||
|
|
||||||
One extra step is required if you run RouterOS v6:
|
Run the complete base installation:
|
||||||
|
|
||||||
:global ScriptUpdatesUrlSuffix "\?h=routeros-v6";
|
|
||||||
|
|
||||||
Then run the complete base installation:
|
|
||||||
|
|
||||||
{
|
{
|
||||||
:global ScriptUpdatesUrlSuffix;
|
|
||||||
/ tool fetch "https://git.eworm.de/cgit/routeros-scripts/plain/certs/R3.pem" dst-path="letsencrypt-R3.pem" as-value;
|
/ tool fetch "https://git.eworm.de/cgit/routeros-scripts/plain/certs/R3.pem" dst-path="letsencrypt-R3.pem" as-value;
|
||||||
:delay 1s;
|
:delay 1s;
|
||||||
/ certificate import file-name=letsencrypt-R3.pem passphrase="";
|
/ certificate import file-name=letsencrypt-R3.pem passphrase="";
|
||||||
|
|
@ -21,8 +17,9 @@ Then run the complete base installation:
|
||||||
:error "Something is wrong with your certificates!";
|
:error "Something is wrong with your certificates!";
|
||||||
};
|
};
|
||||||
/ file remove "letsencrypt-R3.pem";
|
/ file remove "letsencrypt-R3.pem";
|
||||||
|
:delay 1s;
|
||||||
:foreach Script in={ "global-config"; "global-config-overlay"; "global-functions" } do={
|
:foreach Script in={ "global-config"; "global-config-overlay"; "global-functions" } do={
|
||||||
/ system script add name=$Script source=([ / tool fetch check-certificate=yes-without-crl ("https://git.eworm.de/cgit/routeros-scripts/plain/" . $Script . $ScriptUpdatesUrlSuffix) output=user as-value]->"data");
|
/ system script add name=$Script source=([ / tool fetch check-certificate=yes-without-crl ("https://git.eworm.de/cgit/routeros-scripts/plain/" . $Script . "\?h=routeros-v6") output=user as-value]->"data");
|
||||||
};
|
};
|
||||||
/ system script { run global-config; run global-functions; };
|
/ system script { run global-config; run global-functions; };
|
||||||
/ system scheduler add name="global-scripts" start-time=startup on-event="/ system script { run global-config; run global-functions; }";
|
/ system scheduler add name="global-scripts" start-time=startup on-event="/ system script { run global-config; run global-functions; }";
|
||||||
|
|
|
||||||
2
Makefile
|
|
@ -6,7 +6,7 @@ TEMPLATE = $(wildcard *.template)
|
||||||
CAPSMAN = $(TEMPLATE:.template=.capsman)
|
CAPSMAN = $(TEMPLATE:.template=.capsman)
|
||||||
LOCAL = $(TEMPLATE:.template=.local)
|
LOCAL = $(TEMPLATE:.template=.local)
|
||||||
|
|
||||||
MARKDOWN = $(wildcard *.md) $(wildcard doc/*.md)
|
MARKDOWN = $(wildcard *.md doc/*.md doc/mod/*.md)
|
||||||
HTML = $(MARKDOWN:.md=.html)
|
HTML = $(MARKDOWN:.md=.html)
|
||||||
|
|
||||||
all: $(CAPSMAN) $(LOCAL) $(HTML)
|
all: $(CAPSMAN) $(LOCAL) $(HTML)
|
||||||
|
|
|
||||||
BIN
README.d/12-install-custom-script.avif
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
3
README.d/hello-world.rsc
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!rsc by RouterOS
|
||||||
|
|
||||||
|
:put ("Hello World from " . [ / system identity get name ] . "!");
|
||||||
58
README.md
|
|
@ -40,8 +40,8 @@ RouterOS script distribution](https://www.youtube.com/watch?v=B9neG3oAhcY)
|
||||||
including demonstation recorded live at [MUM Europe
|
including demonstation recorded live at [MUM Europe
|
||||||
2019](https://mum.mikrotik.com/2019/EU/) in Vienna.
|
2019](https://mum.mikrotik.com/2019/EU/) in Vienna.
|
||||||
|
|
||||||
*Be warned!* Some details changed. So see the presentation, then follow
|
> ⚠️ **Warning**: Some details changed. So see the presentation, then follow
|
||||||
the steps below for up-to-date commands.
|
> the steps below for up-to-date commands.
|
||||||
|
|
||||||
### The long way in detail
|
### The long way in detail
|
||||||
|
|
||||||
|
|
@ -82,14 +82,9 @@ All following commands will verify the server certificate. For validity the
|
||||||
certificate's lifetime is checked with local time, so make sure the device's
|
certificate's lifetime is checked with local time, so make sure the device's
|
||||||
date and time is set correctly!
|
date and time is set correctly!
|
||||||
|
|
||||||
One extra step is required if you run RouterOS v6:
|
|
||||||
|
|
||||||
:global ScriptUpdatesUrlSuffix "\?h=routeros-v6";
|
|
||||||
|
|
||||||
Now let's download the main scripts and add them in configuration on the fly.
|
Now let's download the main scripts and add them in configuration on the fly.
|
||||||
|
|
||||||
:global ScriptUpdatesUrlSuffix;
|
:foreach Script in={ "global-config"; "global-config-overlay"; "global-functions" } do={ / system script add name=$Script source=([ / tool fetch check-certificate=yes-without-crl ("https://git.eworm.de/cgit/routeros-scripts/plain/" . $Script . "\?h=routeros-v6") output=user as-value]->"data"); };
|
||||||
:foreach Script in={ "global-config"; "global-config-overlay"; "global-functions" } do={ / system script add name=$Script source=([ / tool fetch check-certificate=yes-without-crl ("https://git.eworm.de/cgit/routeros-scripts/plain/" . $Script . $ScriptUpdatesUrlSuffix) output=user as-value]->"data"); };
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
@ -118,10 +113,8 @@ to be updated automatically!
|
||||||
|
|
||||||
### Changes for RouterOS v6
|
### Changes for RouterOS v6
|
||||||
|
|
||||||
RouterOS v6 will become deprecated at some time in the future, but to date
|
Let's consider RouterOS v6 being legacy. If you want to stay with RouterOS
|
||||||
it is still the default for these scripts (in branch `main`). This will
|
v6 for some time add these lines to your `global-config-overlay`, if missing:
|
||||||
change however, so if you want to stay with RouterOS v6 for some time add
|
|
||||||
these lines to your `global-config-overlay`, if missing:
|
|
||||||
|
|
||||||
# Use branch routeros-v6 with RouterOS v6:
|
# Use branch routeros-v6 with RouterOS v6:
|
||||||
:global ScriptUpdatesUrlSuffix "\?h=routeros-v6";
|
:global ScriptUpdatesUrlSuffix "\?h=routeros-v6";
|
||||||
|
|
@ -130,15 +123,8 @@ Then reload the configuration.
|
||||||
|
|
||||||
### Changes for RouterOS v7
|
### Changes for RouterOS v7
|
||||||
|
|
||||||
RouterOS v7 is developed in paralled to RouterOS v6. The former brings some
|
RouterOS v7 is the future, and default branch `main` expects it. Just drop
|
||||||
shiny new features, the latter provides proven stability.
|
`$ScriptUpdatesUrlSuffix` from your `global-config-overlay` to use that.
|
||||||
|
|
||||||
The changes require incompatible changes to scripts, so these changes go to
|
|
||||||
a separate branch. If you decide to run RouterOS v7 please switch to branch
|
|
||||||
`routeros-v7` by adding these lines to your `global-config-overlay`:
|
|
||||||
|
|
||||||
# Use branch routeros-v7 with RouterOS v7:
|
|
||||||
:global ScriptUpdatesUrlSuffix "\?h=routeros-v7";
|
|
||||||
|
|
||||||
Then reload the configuration and continue below to update scripts.
|
Then reload the configuration and continue below to update scripts.
|
||||||
|
|
||||||
|
|
@ -192,6 +178,7 @@ Available scripts
|
||||||
* [Find and remove access list duplicates](doc/accesslist-duplicates.md)
|
* [Find and remove access list duplicates](doc/accesslist-duplicates.md)
|
||||||
* [Upload backup to Mikrotik cloud](doc/backup-cloud.md)
|
* [Upload backup to Mikrotik cloud](doc/backup-cloud.md)
|
||||||
* [Send backup via e-mail](doc/backup-email.md)
|
* [Send backup via e-mail](doc/backup-email.md)
|
||||||
|
* [Save configuration to fallback partition](doc/backup-partition.md)
|
||||||
* [Upload backup to server](doc/backup-upload.md)
|
* [Upload backup to server](doc/backup-upload.md)
|
||||||
* [Download packages for CAP upgrade from CAPsMAN](doc/capsman-download-packages.md)
|
* [Download packages for CAP upgrade from CAPsMAN](doc/capsman-download-packages.md)
|
||||||
* [Run rolling CAP upgrades from CAPsMAN](doc/capsman-rolling-upgrade.md)
|
* [Run rolling CAP upgrades from CAPsMAN](doc/capsman-rolling-upgrade.md)
|
||||||
|
|
@ -204,6 +191,7 @@ Available scripts
|
||||||
* [Use wireless network with daily psk](doc/daily-psk.md)
|
* [Use wireless network with daily psk](doc/daily-psk.md)
|
||||||
* [Comment DHCP leases with info from access list](doc/dhcp-lease-comment.md)
|
* [Comment DHCP leases with info from access list](doc/dhcp-lease-comment.md)
|
||||||
* [Create DNS records for DHCP leases](doc/dhcp-to-dns.md)
|
* [Create DNS records for DHCP leases](doc/dhcp-to-dns.md)
|
||||||
|
* [Automatically upgrade firmware and reboot](doc/firmware-upgrade-reboot.md)
|
||||||
* [Wait for global functions und modules](doc/global-wait.md)
|
* [Wait for global functions und modules](doc/global-wait.md)
|
||||||
* [Send GPS position to server](doc/gps-track.md)
|
* [Send GPS position to server](doc/gps-track.md)
|
||||||
* [Use WPA2 network with hotspot credentials](doc/hotspot-to-wpa.md)
|
* [Use WPA2 network with hotspot credentials](doc/hotspot-to-wpa.md)
|
||||||
|
|
@ -238,6 +226,34 @@ Available modules
|
||||||
|
|
||||||
* [Manage ports in bridge](doc/mod/bridge-port-to.md)
|
* [Manage ports in bridge](doc/mod/bridge-port-to.md)
|
||||||
* [Manage VLANs on bridge ports](doc/mod/bridge-port-vlan.md)
|
* [Manage VLANs on bridge ports](doc/mod/bridge-port-vlan.md)
|
||||||
|
* [Inspect variables](doc/mod/inspectvar.md)
|
||||||
|
* [IP address calculation](doc/mod/ipcalc.md)
|
||||||
|
* [Send notifications via Matrix](doc/mod/notification-matrix.md)
|
||||||
|
* [Send notifications via Telegram](doc/mod/notification-telegram.md)
|
||||||
|
* [Download script and run it once](doc/mod/scriptrunonce.md)
|
||||||
|
|
||||||
|
Installing custom scripts & modules
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
My scripts cover a lot of use cases, but you may have your own ones. You can
|
||||||
|
still use my scripts to manage and deploy yours, by specifying `base-url`
|
||||||
|
(and `url-suffix`) for each script.
|
||||||
|
|
||||||
|
This will fetch and install a script `hello-world.rsc` from the given url:
|
||||||
|
|
||||||
|
$ScriptInstallUpdate hello-world.rsc "base-url=https://git.eworm.de/cgit/routeros-scripts/plain/README.d/"
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
(Yes, the example url still belongs to the repository for easy
|
||||||
|
handling - but the url can be what ever you use.)
|
||||||
|
|
||||||
|
For a script to be considered valid it has to begin with a *magic token*.
|
||||||
|
Have a look at [any script](README.d/hello-world.rsc) and copy the first line
|
||||||
|
without modification.
|
||||||
|
|
||||||
|
Starting a script's name with `mod/` makes it a module and it is run
|
||||||
|
automatically by `global-functions`.
|
||||||
|
|
||||||
Contact
|
Contact
|
||||||
-------
|
-------
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
:global GlobalFunctionsReady;
|
:global GlobalFunctionsReady;
|
||||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
:local Read do={ :return; }
|
:global Read;
|
||||||
|
|
||||||
:local Seen [ :toarray "" ];
|
:local Seen [ :toarray "" ];
|
||||||
:local Shown [ :toarray "" ];
|
:local Shown [ :toarray "" ];
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
:global GlobalFunctionsReady;
|
:global GlobalFunctionsReady;
|
||||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
:local Read do={ :return; }
|
:global Read;
|
||||||
|
|
||||||
:local Seen [ :toarray "" ];
|
:local Seen [ :toarray "" ];
|
||||||
:local Shown [ :toarray "" ];
|
:local Shown [ :toarray "" ];
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
:global GlobalFunctionsReady;
|
:global GlobalFunctionsReady;
|
||||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
:local Read do={ :return; }
|
:global Read;
|
||||||
|
|
||||||
:local Seen [ :toarray "" ];
|
:local Seen [ :toarray "" ];
|
||||||
:local Shown [ :toarray "" ];
|
:local Shown [ :toarray "" ];
|
||||||
|
|
|
||||||
36
backup-partition
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#!rsc by RouterOS
|
||||||
|
# RouterOS script: backup-partition
|
||||||
|
# Copyright (c) 2022 Christian Hesse <mail@eworm.de>
|
||||||
|
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
||||||
|
#
|
||||||
|
# provides: backup-script
|
||||||
|
#
|
||||||
|
# save configuration to fallback partition
|
||||||
|
# https://git.eworm.de/cgit/routeros-scripts/about/doc/backup-partition.md
|
||||||
|
|
||||||
|
:local 0 "backup-partition";
|
||||||
|
:global GlobalFunctionsReady;
|
||||||
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
|
:global LogPrintExit2;
|
||||||
|
|
||||||
|
:if ([ :len [ / partitions find ] ] < 2) do={
|
||||||
|
$LogPrintExit2 error $0 ("Device does not have a fallback partition.") true;
|
||||||
|
}
|
||||||
|
|
||||||
|
:local ActiveRunning [ / partitions find where active running ];
|
||||||
|
|
||||||
|
:if ([ :len $ActiveRunning ] < 1) do={
|
||||||
|
$LogPrintExit2 error $0 ("Device is not running from active partition.") true;
|
||||||
|
}
|
||||||
|
|
||||||
|
:local ActiveRunningVar [ / partitions get $ActiveRunning ];
|
||||||
|
|
||||||
|
:do {
|
||||||
|
/ partitions save-config-to ($ActiveRunningVar->"fallback-to");
|
||||||
|
$LogPrintExit2 info $0 ("Saved configuration to partition '" . \
|
||||||
|
($ActiveRunningVar->"fallback-to") . "'.") false;
|
||||||
|
} on-error={
|
||||||
|
$LogPrintExit2 error $0 ("Failed saving configuration to partition '" . \
|
||||||
|
($ActiveRunningVar->"fallback-to") . "'!") true;
|
||||||
|
}
|
||||||
|
|
@ -47,12 +47,39 @@ $WaitFullyConnected;
|
||||||
:if ($File->"package-name" = "wireless@") do={
|
:if ($File->"package-name" = "wireless@") do={
|
||||||
:set ($File->"package-name") "wireless";
|
:set ($File->"package-name") "wireless";
|
||||||
}
|
}
|
||||||
:if ([ $DownloadPackage ($File->"package-name") $InstalledVersion ($File->"package-architecture") $PackagePath ] = true) do={
|
:if ([ $DownloadPackage ($File->"package-name") $InstalledVersion \
|
||||||
|
($File->"package-architecture") $PackagePath ] = true) do={
|
||||||
:set Updated true;
|
:set Updated true;
|
||||||
/ file remove $Package;
|
/ file remove $Package;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:if ([ :len [ / system logging find where topics~"error" !(topics~"!error") \
|
||||||
|
!(topics~"!caps") action=memory !disabled !invalid ] ] < 1) do={
|
||||||
|
$LogPrintExit2 warning $0 ("Looks like error messages for 'caps' are not sent to memory. " . \
|
||||||
|
"Probably can not download packages automatically.") false;
|
||||||
|
} else={
|
||||||
|
:if ($Updated = false && [ / system resource get uptime ] < 2m) do={
|
||||||
|
$LogPrintExit2 info $0 ("No packages downloaded, yet. Delaying for logs.") false;
|
||||||
|
:delay 2m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:foreach Log in=[ / log find where topics=({"caps", "error"}) \
|
||||||
|
message~("upgrade status: failed, failed to download file '.*-" . $InstalledVersion . \
|
||||||
|
"-.*\\.npk', no such file") ] do={
|
||||||
|
:local Message [ / log get $Log message ];
|
||||||
|
:local Package [ :pick $Message \
|
||||||
|
([ :find $Message "'" ] + 1) \
|
||||||
|
[ :find $Message ("-" . $InstalledVersion . "-") ] ];
|
||||||
|
:local Arch [ :pick $Message \
|
||||||
|
([ :find $Message ("-" . $InstalledVersion . "-") ] + 2 + [ :len $InstalledVersion ]) \
|
||||||
|
[ :find $Message ".npk" ] ];
|
||||||
|
:if ([ $DownloadPackage $Package $InstalledVersion $Arch $PackagePath ] = true) do={
|
||||||
|
:set Updated true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
:if ($Updated = true) do={
|
:if ($Updated = true) do={
|
||||||
:if ([ :len [ / system script find where name="capsman-rolling-upgrade" ] ] > 0) do={
|
:if ([ :len [ / system script find where name="capsman-rolling-upgrade" ] ] > 0) do={
|
||||||
/ system script run capsman-rolling-upgrade;
|
/ system script run capsman-rolling-upgrade;
|
||||||
|
|
|
||||||
|
|
@ -10,37 +10,73 @@
|
||||||
:global GlobalFunctionsReady;
|
:global GlobalFunctionsReady;
|
||||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
:global Identity;
|
|
||||||
:global SentLteFirmwareUpgradeNotification;
|
:global SentLteFirmwareUpgradeNotification;
|
||||||
|
|
||||||
:global CharacterReplace;
|
:if ([ :typeof $SentLteFirmwareUpgradeNotification ] != "array") do={
|
||||||
:global LogPrintExit2;
|
:global SentLteFirmwareUpgradeNotification [ :toarray "" ];
|
||||||
:global SendNotification2;
|
}
|
||||||
:global SymbolForNotification;
|
|
||||||
|
:local CheckInterface do={
|
||||||
|
:local Interface $1;
|
||||||
|
|
||||||
|
:global Identity;
|
||||||
|
:global SentLteFirmwareUpgradeNotification;
|
||||||
|
|
||||||
|
:global CharacterReplace;
|
||||||
|
:global LogPrintExit2;
|
||||||
|
:global ScriptFromTerminal;
|
||||||
|
:global SendNotification2;
|
||||||
|
:global SymbolForNotification;
|
||||||
|
|
||||||
:foreach Interface in=[ / interface lte find ] do={
|
|
||||||
:local IntName [ / interface lte get $Interface name ];
|
:local IntName [ / interface lte get $Interface name ];
|
||||||
|
:local Firmware;
|
||||||
|
:local Info;
|
||||||
:do {
|
:do {
|
||||||
:local Firmware [ / interface lte firmware-upgrade $Interface once as-value ];
|
:set Firmware [ / interface lte firmware-upgrade $Interface once as-value ];
|
||||||
|
:set Info [ / interface lte info $Interface once as-value ];
|
||||||
:if ($SentLteFirmwareUpgradeNotification = ($Firmware->"latest")) do={
|
|
||||||
$LogPrintExit2 debug $0 ("Already sent the LTE firmware upgrade notification for version " . \
|
|
||||||
($Firmware->"latest") . ".") false;
|
|
||||||
} else={
|
|
||||||
:if (($Firmware->"installed") != ($Firmware->"latest")) do={
|
|
||||||
:local Info [ / interface lte info $Interface once as-value ];
|
|
||||||
$SendNotification2 ({ origin=$0; \
|
|
||||||
subject=([ $SymbolForNotification "sparkles" ] . "LTE firmware upgrade"); \
|
|
||||||
message=("A new firmware version " . ($Firmware->"latest") . " is available for " . \
|
|
||||||
"LTE interface " . $IntName . " on " . $Identity . ".\n\n" . \
|
|
||||||
"Interface: " . [ $CharacterReplace ($Info->"manufacturer" . " " . $Info->"model") ("\"") "" ] . "\n" . \
|
|
||||||
"Installed: " . ($Firmware->"installed") . "\n" . \
|
|
||||||
"Available: " . ($Firmware->"latest")); silent=true });
|
|
||||||
:set SentLteFirmwareUpgradeNotification ($Firmware->"latest");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit2 debug $0 ("Could not get latest LTE firmware version for interface " . \
|
$LogPrintExit2 debug $0 ("Could not get latest LTE firmware version for interface " . \
|
||||||
$IntName . ".") false;
|
$IntName . ".") false;
|
||||||
|
:return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:if (($Firmware->"installed") = ($Firmware->"latest")) do={
|
||||||
|
:if ([ $ScriptFromTerminal "check-lte-firmware-upgrade" ] = true) do={
|
||||||
|
$LogPrintExit2 info $0 ("No firmware upgrade available for LTE interface " . $IntName . ".") false;
|
||||||
|
}
|
||||||
|
:return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
:if ([ $ScriptFromTerminal "check-lte-firmware-upgrade" ] = true && \
|
||||||
|
[ :len [ / system script find where name="unattended-lte-firmware-upgrade" ] ] > 0) do={
|
||||||
|
:put ("Do you want to start unattended lte firmware upgrade for interface " . $IntName . "? [y/N]");
|
||||||
|
:if (([ / terminal inkey timeout=60 ] % 32) = 25) do={
|
||||||
|
/ system script run unattended-lte-firmware-upgrade;
|
||||||
|
$LogPrintExit2 info $0 ("Scheduled lte firmware upgrade for interface " . $IntName . "...") false;
|
||||||
|
:return true;
|
||||||
|
} else={
|
||||||
|
:put "Canceled...";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:if (($SentLteFirmwareUpgradeNotification->$IntName) = ($Firmware->"latest")) do={
|
||||||
|
$LogPrintExit2 debug $0 ("Already sent the LTE firmware upgrade notification for version " . \
|
||||||
|
($Firmware->"latest") . ".") false;
|
||||||
|
:return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$LogPrintExit2 info $0 ("A new firmware version " . ($Firmware->"latest") . " is available for " . \
|
||||||
|
"LTE interface " . $IntName . ".") false;
|
||||||
|
$SendNotification2 ({ origin=$0; \
|
||||||
|
subject=([ $SymbolForNotification "sparkles" ] . "LTE firmware upgrade"); \
|
||||||
|
message=("A new firmware version " . ($Firmware->"latest") . " is available for " . \
|
||||||
|
"LTE interface " . $IntName . " on " . $Identity . ".\n\n" . \
|
||||||
|
"Interface: " . [ $CharacterReplace ($Info->"manufacturer" . " " . $Info->"model") ("\"") "" ] . "\n" . \
|
||||||
|
"Installed: " . ($Firmware->"installed") . "\n" . \
|
||||||
|
"Available: " . ($Firmware->"latest")); silent=true });
|
||||||
|
:set ($SentLteFirmwareUpgradeNotification->$IntName) ($Firmware->"latest");
|
||||||
|
}
|
||||||
|
|
||||||
|
:foreach Interface in=[ / interface lte find ] do={
|
||||||
|
$CheckInterface $Interface;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ $LogPrintExit2 debug $0 ("Checking for updates...") false;
|
||||||
|
|
||||||
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
||||||
:put ("Do you want to install RouterOS version " . $Update->"latest-version" . "? [y/N]");
|
:put ("Do you want to install RouterOS version " . $Update->"latest-version" . "? [y/N]");
|
||||||
:if (([ :terminal inkey timeout=60 ] % 32) = 25) do={
|
:if (([ / terminal inkey timeout=60 ] % 32) = 25) do={
|
||||||
$DoUpdate;
|
$DoUpdate;
|
||||||
} else={
|
} else={
|
||||||
:put "Canceled...";
|
:put "Canceled...";
|
||||||
|
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
#!rsc by RouterOS
|
|
||||||
# dummy for migration
|
|
||||||
|
|
@ -3,8 +3,8 @@ Find and remove access list duplicates
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,19 @@ Upload backup to Mikrotik cloud
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
This script uploads [binary backup to Mikrotik cloud](https://wiki.mikrotik.com/wiki/Manual:IP/Cloud#Backup).
|
This script uploads
|
||||||
|
[binary backup to Mikrotik cloud](https://wiki.mikrotik.com/wiki/Manual:IP/Cloud#Backup).
|
||||||
|
|
||||||
|
> ⚠️ **Warning**: The used command can hit errors that a script can not handle.
|
||||||
|
> This may result in script termination (where no notification is sent) or
|
||||||
|
> malfunction of fetch command (where all up- and downloads break) for some
|
||||||
|
> time. Failed notifications are queued then.
|
||||||
|
|
||||||
### Sample notification
|
### Sample notification
|
||||||
|
|
||||||
|
|
@ -30,7 +36,9 @@ The configuration goes to `global-config-overlay`, these are the parameters:
|
||||||
* `BackupPassword`: password to encrypt the backup with
|
* `BackupPassword`: password to encrypt the backup with
|
||||||
* `BackupRandomDelay`: delay up to amount of seconds when run from scheduler
|
* `BackupRandomDelay`: delay up to amount of seconds when run from scheduler
|
||||||
|
|
||||||
Also notification settings are required for e-mail, matrix and/or telegram.
|
Also notification settings are required for e-mail,
|
||||||
|
[matrix](mod/notification-matrix.md) and/or
|
||||||
|
[telegram](mod/notification-telegram.md).
|
||||||
|
|
||||||
Usage and invocation
|
Usage and invocation
|
||||||
--------------------
|
--------------------
|
||||||
|
|
@ -47,6 +55,7 @@ See also
|
||||||
--------
|
--------
|
||||||
|
|
||||||
* [Send backup via e-mail](backup-email.md)
|
* [Send backup via e-mail](backup-email.md)
|
||||||
|
* [Save configuration to fallback partition](doc/backup-partition.md)
|
||||||
* [Upload backup to server](backup-upload.md)
|
* [Upload backup to server](backup-upload.md)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Send backup via e-mail
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -12,7 +12,6 @@ Description
|
||||||
This script sends binary backup (`/ system backup save`) and complete
|
This script sends binary backup (`/ system backup save`) and complete
|
||||||
configuration export (`/ export terse`) via e-mail.
|
configuration export (`/ export terse`) via e-mail.
|
||||||
|
|
||||||
|
|
||||||
Requirements and installation
|
Requirements and installation
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
|
|
@ -47,6 +46,7 @@ See also
|
||||||
--------
|
--------
|
||||||
|
|
||||||
* [Upload backup to Mikrotik cloud](backup-cloud.md)
|
* [Upload backup to Mikrotik cloud](backup-cloud.md)
|
||||||
|
* [Save configuration to fallback partition](doc/backup-partition.md)
|
||||||
* [Upload backup to server](backup-upload.md)
|
* [Upload backup to server](backup-upload.md)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
||||||
45
doc/backup-partition.md
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
Save configuration to fallback partition
|
||||||
|
========================================
|
||||||
|
|
||||||
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
This script saves the current configuration to fallback
|
||||||
|
[partition](https://wiki.mikrotik.com/wiki/Manual:Partitions).
|
||||||
|
|
||||||
|
For this to work you need a device with sufficient flash storage that is
|
||||||
|
properly partitioned.
|
||||||
|
|
||||||
|
Requirements and installation
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Just install the script:
|
||||||
|
|
||||||
|
$ScriptInstallUpdate backup-partition;
|
||||||
|
|
||||||
|
Usage and invocation
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Just run the script:
|
||||||
|
|
||||||
|
/ system script run backup-partition;
|
||||||
|
|
||||||
|
Creating a scheduler may be an option:
|
||||||
|
|
||||||
|
/ system scheduler add interval=1w name=backup-partition on-event="/ system script run backup-partition;" start-time=09:30:00;
|
||||||
|
|
||||||
|
See also
|
||||||
|
--------
|
||||||
|
|
||||||
|
* [Upload backup to Mikrotik cloud](backup-cloud.md)
|
||||||
|
* [Send backup via e-mail](backup-email.md)
|
||||||
|
* [Upload backup to server](backup-upload.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
[◀ Go back to main README](../README.md)
|
||||||
|
[▲ Go back to top](#top)
|
||||||
|
|
@ -3,8 +3,8 @@ Upload backup to server
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -12,6 +12,11 @@ Description
|
||||||
This script uploads binary backup (`/ system backup save`) and complete
|
This script uploads binary backup (`/ system backup save`) and complete
|
||||||
configuration export (`/ export terse`) to external server.
|
configuration export (`/ export terse`) to external server.
|
||||||
|
|
||||||
|
> ⚠️ **Warning**: The used command can hit errors that a script can not handle.
|
||||||
|
> This may result in script termination (where no notification is sent) or
|
||||||
|
> malfunction of fetch command (where all up- and downloads break) for some
|
||||||
|
> time. Failed notifications are queued then.
|
||||||
|
|
||||||
### Sample notification
|
### Sample notification
|
||||||
|
|
||||||

|

|
||||||
|
|
@ -36,7 +41,9 @@ The configuration goes to `global-config-overlay`, these are the parameters:
|
||||||
* `BackupUploadUser`: username for server authentication
|
* `BackupUploadUser`: username for server authentication
|
||||||
* `BackupUploadPass`: password for server authentication
|
* `BackupUploadPass`: password for server authentication
|
||||||
|
|
||||||
Also notification settings are required for e-mail, matrix and/or telegram.
|
Also notification settings are required for e-mail,
|
||||||
|
[matrix](mod/notification-matrix.md) and/or
|
||||||
|
[telegram](mod/notification-telegram.md).
|
||||||
|
|
||||||
### Issues with SFTP client
|
### Issues with SFTP client
|
||||||
|
|
||||||
|
|
@ -62,8 +69,9 @@ Creating a scheduler may be an option:
|
||||||
See also
|
See also
|
||||||
--------
|
--------
|
||||||
|
|
||||||
* [Send backup via e-mail](backup-email.md)
|
|
||||||
* [Upload backup to Mikrotik cloud](backup-cloud.md)
|
* [Upload backup to Mikrotik cloud](backup-cloud.md)
|
||||||
|
* [Send backup via e-mail](backup-email.md)
|
||||||
|
* [Save configuration to fallback partition](doc/backup-partition.md)
|
||||||
|
|
||||||
---
|
---
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Download packages for CAP upgrade from CAPsMAN
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -26,18 +26,9 @@ Optionally add a scheduler to run after startup:
|
||||||
|
|
||||||
/ system scheduler add name=capsman-download-packages on-event="/ system script run capsman-download-packages;" start-time=startup;
|
/ system scheduler add name=capsman-download-packages on-event="/ system script run capsman-download-packages;" start-time=startup;
|
||||||
|
|
||||||
Only packages available in older version are downloaded. For initial setup
|
Packages available in local storage in older version are downloaded
|
||||||
place the required packages to CAPsMAN package path (see
|
unconditionally. The script tries to download missing packages by guessing
|
||||||
`/ caps-man manager`). The packages can be downloaded from device with
|
from system log.
|
||||||
function `$DownloadPackage`, use something like this to download latest
|
|
||||||
packages to directory `routeros`:
|
|
||||||
|
|
||||||
$DownloadPackage system "" arm routeros;
|
|
||||||
$DownloadPackage security "" arm routeros;
|
|
||||||
[...]
|
|
||||||
$DownloadPackage system "" mipsbe routeros;
|
|
||||||
$DownloadPackage security "" mipsbe routeros;
|
|
||||||
[...]
|
|
||||||
|
|
||||||
Usage and invocation
|
Usage and invocation
|
||||||
--------------------
|
--------------------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Run rolling CAP upgrades from CAPsMAN
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Renew locally issued certificates
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Renew certificates and notify on expiration
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -27,7 +27,8 @@ Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
The expiry notifications just require notification settings for e-mail,
|
The expiry notifications just require notification settings for e-mail,
|
||||||
matrix and/or telegram.
|
[matrix](mod/notification-matrix.md) and/or
|
||||||
|
[telegram](mod/notification-telegram.md).
|
||||||
|
|
||||||
For automatic download and renewal of certificates you need configuration
|
For automatic download and renewal of certificates you need configuration
|
||||||
in `global-config-overlay`, these are the parameters:
|
in `global-config-overlay`, these are the parameters:
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Notify about health state
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -56,7 +56,9 @@ The configuration goes to `global-config-overlay`, these are the parameters:
|
||||||
* `CheckHealthVoltageLow`: value (in volt*10) giving a hard lower limit
|
* `CheckHealthVoltageLow`: value (in volt*10) giving a hard lower limit
|
||||||
* `CheckHealthVoltagePercent`: percentage value to trigger voltage jumps
|
* `CheckHealthVoltagePercent`: percentage value to trigger voltage jumps
|
||||||
|
|
||||||
Also notification settings are required for e-mail, matrix and/or telegram.
|
Also notification settings are required for e-mail,
|
||||||
|
[matrix](mod/notification-matrix.md) and/or
|
||||||
|
[telegram](mod/notification-telegram.md).
|
||||||
|
|
||||||
---
|
---
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Notify on LTE firmware upgrade
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -35,7 +35,9 @@ Just install the script:
|
||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
Notification setting are required for e-mail, matrix and/or telegram.
|
Notification setting are required for e-mail,
|
||||||
|
[matrix](mod/notification-matrix.md) and/or
|
||||||
|
[telegram](mod/notification-telegram.md).
|
||||||
|
|
||||||
See also
|
See also
|
||||||
--------
|
--------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Notify on RouterOS update
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -14,11 +14,20 @@ The primary use of this script is to notify about RouterOS updates.
|
||||||
Run from a terminal you can start the update process or schedule it.
|
Run from a terminal you can start the update process or schedule it.
|
||||||
|
|
||||||
Centrally managing update process of several devices is possibly by
|
Centrally managing update process of several devices is possibly by
|
||||||
specifying versions safe to be updated on a web server.
|
specifying versions safe to be updated on a web server. Versions seen
|
||||||
|
in neighbor discovery can be specified to be safe as well.
|
||||||
|
|
||||||
Also installing patch updates (where just last digit is increased)
|
Also installing patch updates (where just last digit is increased)
|
||||||
automatically is supported.
|
automatically is supported.
|
||||||
|
|
||||||
|
> ⚠️ **Warning**: Installing updates is important from a security point
|
||||||
|
> of view. At the same time it can be source of serve breakage. So test
|
||||||
|
> versions in lab and read
|
||||||
|
> [changelog](https://mikrotik.com/download/changelogs/) and
|
||||||
|
> [forum](https://forum.mikrotik.com/viewforum.php?f=21) before deploying
|
||||||
|
> to your production environment! Automatic updates should be handled
|
||||||
|
> with care!
|
||||||
|
|
||||||
### Sample notification
|
### Sample notification
|
||||||
|
|
||||||

|

|
||||||
|
|
@ -47,6 +56,10 @@ safe versions from a web server. The configuration goes to
|
||||||
* `SafeUpdateUrl`: url to check for safe update, the channel (`long-term`,
|
* `SafeUpdateUrl`: url to check for safe update, the channel (`long-term`,
|
||||||
`stable` or `testing`) is appended
|
`stable` or `testing`) is appended
|
||||||
|
|
||||||
|
Also notification settings are required for e-mail,
|
||||||
|
[matrix](mod/notification-matrix.md) and/or
|
||||||
|
[telegram](mod/notification-telegram.md).
|
||||||
|
|
||||||
Usage and invocation
|
Usage and invocation
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
|
@ -61,6 +74,7 @@ Installing script [packages-update](packages-update.md) gives extra options.
|
||||||
See also
|
See also
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
* [Automatically upgrade firmware and reboot](firmware-upgrade-reboot.md)
|
||||||
* [Manage system update](packages-update.md)
|
* [Manage system update](packages-update.md)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Collect MAC addresses in wireless access list
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -40,7 +40,9 @@ On first run a disabled access list entry acting as marker (with comment
|
||||||
"`--- collected above ---`") is added. Move this entry to define where new
|
"`--- collected above ---`") is added. Move this entry to define where new
|
||||||
entries are to be added.
|
entries are to be added.
|
||||||
|
|
||||||
Also notification settings are required for e-mail, matrix and/or telegram.
|
Also notification settings are required for e-mail,
|
||||||
|
[matrix](mod/notification-matrix.md) and/or
|
||||||
|
[telegram](mod/notification-telegram.md).
|
||||||
|
|
||||||
Usage and invocation
|
Usage and invocation
|
||||||
--------------------
|
--------------------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Use wireless network with daily psk
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -51,7 +51,9 @@ Then add an access list entry:
|
||||||
|
|
||||||
/ interface wireless access-list add comment="Daily PSK" interface=wl-daily private-pre-shared-key="ToBeChangedDaily";
|
/ interface wireless access-list add comment="Daily PSK" interface=wl-daily private-pre-shared-key="ToBeChangedDaily";
|
||||||
|
|
||||||
Also notification settings are required for e-mail, matrix and/or telegram.
|
Also notification settings are required for e-mail,
|
||||||
|
[matrix](mod/notification-matrix.md) and/or
|
||||||
|
[telegram](mod/notification-telegram.md).
|
||||||
|
|
||||||
---
|
---
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Comment DHCP leases with info from access list
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Create DNS records for DHCP leases
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,2 @@
|
||||||
Send notification with early errors
|
This script has been replaced. Please migrate to
|
||||||
===================================
|
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
|
||||||
|
|
||||||
This script has been replace. Please migrate to
|
|
||||||
[Forward log messages via notification](log-forward.md).
|
[Forward log messages via notification](log-forward.md).
|
||||||
|
|
||||||
---
|
|
||||||
[◀ Go back to main README](../README.md)
|
|
||||||
[▲ Go back to top](#top)
|
|
||||||
|
|
|
||||||
36
doc/firmware-upgrade-reboot.md
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
Automatically upgrade firmware and reboot
|
||||||
|
=========================================
|
||||||
|
|
||||||
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
RouterOS and firmware are upgraded separately, activating the latter
|
||||||
|
requires an extra reboot. This script handles upgrade and reboot.
|
||||||
|
|
||||||
|
> ⚠️ **Warning**: This *should* be bullet proof, but I can not guarantee. In
|
||||||
|
> worst case it has potential to cause a boot loop, so handle with care!
|
||||||
|
|
||||||
|
Requirements and installation
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Just install the script and create a scheduler:
|
||||||
|
|
||||||
|
$ScriptInstallUpdate firmware-upgrade-reboot;
|
||||||
|
/ system scheduler add name=firmware-upgrade-reboot on-event="/ system script run firmware-upgrade-reboot;" start-time=startup;
|
||||||
|
|
||||||
|
Enjoy firmware being up to date and in sync with RouterOS.
|
||||||
|
|
||||||
|
See also
|
||||||
|
--------
|
||||||
|
|
||||||
|
* [Notify on RouterOS update](check-routeros-update.md)
|
||||||
|
* [Manage system update](packages-update.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
[◀ Go back to main README](../README.md)
|
||||||
|
[▲ Go back to top](#top)
|
||||||
|
|
@ -3,8 +3,8 @@ Wait for global functions and modules
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Send GPS position to server
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Use WPA2 network with hotspot credentials
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -56,6 +56,7 @@ Create hotspot login credentials:
|
||||||
|
|
||||||
Additionally templates can be created to give more options for access list:
|
Additionally templates can be created to give more options for access list:
|
||||||
|
|
||||||
|
* `action`: set to `reject` to ignore logins on that hotspot
|
||||||
* `private-passphrase`: do **not** use passphrase from hotspot's user
|
* `private-passphrase`: do **not** use passphrase from hotspot's user
|
||||||
credentials, but given one - or unset (use default passphrase) with
|
credentials, but given one - or unset (use default passphrase) with
|
||||||
special word `ignore`
|
special word `ignore`
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Create DNS records for IPSec peers
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Update configuration on IPv6 prefix change
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,25 @@ Run other scripts on DHCP lease
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
This script is supposed to run from dhcp server as lease script. Currently
|
This script is supposed to run from dhcp server as lease script. On a dhcp
|
||||||
it does:
|
lease it runs each script containing the following line, where `##` is a
|
||||||
|
decimal number for ordering:
|
||||||
|
|
||||||
* run [collect-wireless-mac](collect-wireless-mac.md)
|
# provides: lease-script, order=##
|
||||||
* run [dhcp-lease-comment](dhcp-lease-comment.md)
|
|
||||||
* run [dhcp-to-dns](dhcp-to-dns.md)
|
Currently it runs if available, in order:
|
||||||
* run [hotspot-to-wpa](hotspot-to-wpa.md)
|
|
||||||
|
* [dhcp-to-dns](dhcp-to-dns.md)
|
||||||
|
* [collect-wireless-mac](collect-wireless-mac.md)
|
||||||
|
* [dhcp-lease-comment](dhcp-lease-comment.md)
|
||||||
|
* `hotspot-to-wpa-cleanup`, which is an optional cleanup script
|
||||||
|
of [hotspot-to-wpa](hotspot-to-wpa.md)
|
||||||
|
|
||||||
Requirements and installation
|
Requirements and installation
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Forward log messages via notification
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -46,7 +46,9 @@ The configuration goes to `global-config-overlay`, these are the parameters:
|
||||||
* `LogForwardIncludeMessage`: define message text to be forwarded (even if
|
* `LogForwardIncludeMessage`: define message text to be forwarded (even if
|
||||||
filter matches)
|
filter matches)
|
||||||
|
|
||||||
Also notification settings are required for e-mail, matrix and/or telegram.
|
Also notification settings are required for e-mail,
|
||||||
|
[matrix](mod/notification-matrix.md) and/or
|
||||||
|
[telegram](mod/notification-telegram.md).
|
||||||
|
|
||||||
---
|
---
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
Manage ports in bridge
|
Manage ports in bridge
|
||||||
======================
|
======================
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../../README.md)
|
||||||
|
|
||||||
🛈 This module can not be used on its own but requires the base installation.
|
> ℹ️️ **Info**: This module can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -77,5 +77,5 @@ See also
|
||||||
* [Manage VLANs on bridge ports](bridge-port-vlan.md)
|
* [Manage VLANs on bridge ports](bridge-port-vlan.md)
|
||||||
|
|
||||||
---
|
---
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../../README.md)
|
||||||
[▲ Go back to top](#top)
|
[▲ Go back to top](#top)
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Manage VLANs on bridge ports
|
||||||
|
|
||||||
[◀ Go back to main README](../../README.md)
|
[◀ Go back to main README](../../README.md)
|
||||||
|
|
||||||
🛈 This module can not be used on its own but requires the base installation.
|
> ℹ️️ **Info**: This module can not be used on its own but requires the base
|
||||||
See [main README](../../README.md) for details.
|
> installation. See [main README](../../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
BIN
doc/mod/inspectvar.d/inspectvar.avif
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
33
doc/mod/inspectvar.md
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
Inspect variables
|
||||||
|
=================
|
||||||
|
|
||||||
|
[◀ Go back to main README](../../README.md)
|
||||||
|
|
||||||
|
> ℹ️️ **Info**: This module can not be used on its own but requires the base
|
||||||
|
> installation. See [main README](../../README.md) for details.
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
RouterOS handles not just scalar variables, but also arrays - even nested.
|
||||||
|
This module adds a function to inspect variables.
|
||||||
|
|
||||||
|
Requirements and installation
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Just install the module:
|
||||||
|
|
||||||
|
$ScriptInstallUpdate mod/inspectvar;
|
||||||
|
|
||||||
|
Usage and invocation
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Call the function `$InspectVar` with a variable as parameter:
|
||||||
|
|
||||||
|
$InspectVar $ModeButton
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
[◀ Go back to main README](../../README.md)
|
||||||
|
[▲ Go back to top](#top)
|
||||||
BIN
doc/mod/ipcalc.d/ipcalc.avif
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
doc/mod/ipcalc.d/ipcalcreturn.avif
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
53
doc/mod/ipcalc.md
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
IP address calculation
|
||||||
|
======================
|
||||||
|
|
||||||
|
[◀ Go back to main README](../../README.md)
|
||||||
|
|
||||||
|
> ℹ️️ **Info**: This module can not be used on its own but requires the base
|
||||||
|
> installation. See [main README](../../README.md) for details.
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
This module adds functions for IP address calculation.
|
||||||
|
|
||||||
|
Requirements and installation
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Just install the module:
|
||||||
|
|
||||||
|
$ScriptInstallUpdate mod/ipcalc;
|
||||||
|
|
||||||
|
Usage and invocation
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
### IPCalc
|
||||||
|
|
||||||
|
The function `$IPCalc` prints information to terminal, including:
|
||||||
|
|
||||||
|
* address
|
||||||
|
* netmask
|
||||||
|
* network in CIDR notation
|
||||||
|
* minimum host address
|
||||||
|
* maximum host address
|
||||||
|
* broadcast address
|
||||||
|
|
||||||
|
It expects an IP address in CIDR notation as argument.
|
||||||
|
|
||||||
|
$IPCalc 192.168.88.1/24;
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### IPCalcReturn
|
||||||
|
|
||||||
|
The function `$IPCalcReturn` expects an IP address in CIDR notation as
|
||||||
|
argument as well. But it does not print to terminal, instead it returns
|
||||||
|
the information in a named array.
|
||||||
|
|
||||||
|
:put ([ $IPCalcReturn 192.168.88.1/24 ]->"broadcast");
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
[◀ Go back to main README](../../README.md)
|
||||||
|
[▲ Go back to top](#top)
|
||||||
BIN
doc/mod/notification-matrix.d/01-home-server.avif
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
doc/mod/notification-matrix.d/02-access-token.avif
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
doc/mod/notification-matrix.d/03-join-room.avif
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
100
doc/mod/notification-matrix.md
Normal file
|
|
@ -0,0 +1,100 @@
|
||||||
|
Send notifications via Matrix
|
||||||
|
=============================
|
||||||
|
|
||||||
|
[◀ Go back to main README](../../README.md)
|
||||||
|
|
||||||
|
> ℹ️️ **Info**: This module can not be used on its own but requires the base
|
||||||
|
> installation. See [main README](../../README.md) for details.
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
This module adds support for sending notifications via
|
||||||
|
[Matrix](https://matrix.org/) via client server api. A queue is used to
|
||||||
|
make sure notifications are not lost on failure but sent later.
|
||||||
|
|
||||||
|
Requirements and installation
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Just install the module:
|
||||||
|
|
||||||
|
$ScriptInstallUpdate mod/notification-matrix;
|
||||||
|
|
||||||
|
Also install a Matrix client on at least one of your mobile and/or desktop
|
||||||
|
devices. As there is no privilege separation you should create a dedicated
|
||||||
|
notification account, in addition to your general user account.
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Edit `global-config-overlay`, add `MatrixHomeServer`, `MatrixAccessToken` and
|
||||||
|
`MatrixRoom` - see below on hints how to retrieve this information. Then
|
||||||
|
reload the configuration.
|
||||||
|
|
||||||
|
### Home server
|
||||||
|
|
||||||
|
Matrix user accounts are identified by a unique user id in the form of
|
||||||
|
`@localpart:domain`. The `domain` part is not necessarily your home server
|
||||||
|
address, you have to resolve it with the procedure described in the
|
||||||
|
[Matrix specification](https://spec.matrix.org/latest/client-server-api/#server-discovery).
|
||||||
|
|
||||||
|
Your best bet is to query the server at `domain` with the
|
||||||
|
[well-known uri](https://spec.matrix.org/latest/client-server-api/#well-known-uri).
|
||||||
|
For "*matrix.org*" this query is:
|
||||||
|
|
||||||
|
/ tool fetch "https://matrix.org/.well-known/matrix/client" output=user;
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
So the home server for "*matrix.org*" is "*matrix-client.matrix.org*".
|
||||||
|
Please strip the protocol ("*https://*") for `MatrixHomeServer` if given.
|
||||||
|
|
||||||
|
### Access token
|
||||||
|
|
||||||
|
After discovering the correct home server an access token has to be created.
|
||||||
|
For this the login credentials (username and password) of the notification
|
||||||
|
account must be sent to the home server via
|
||||||
|
[client server api](https://matrix.org/docs/guides/client-server-api#login).
|
||||||
|
|
||||||
|
We use the home server discovered above, "*matrix-client.matrix.org*".
|
||||||
|
The user is "*example*" and password is "*v3ry-s3cr3t*".
|
||||||
|
|
||||||
|
/ tool fetch "https://matrix-client.matrix.org/_matrix/client/r0/login" http-method=post http-data="{\"type\":\"m.login.password\", \"user\":\"example\", \"password\":\"v3ry-s3cr3t\"}" output=user;
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The server replied with a JSON object containing the `access_token`, use that
|
||||||
|
for `MatrixAccessToken`.
|
||||||
|
|
||||||
|
### Room
|
||||||
|
|
||||||
|
Every Matix chat is a room, so we have to create one. Do so with your general
|
||||||
|
user, this makes sure your general user is the room owner. Then join the room
|
||||||
|
and invite the notification user by its user id "*@example:matrix.org*". Look
|
||||||
|
up the room id within the Matrix client, it should read like
|
||||||
|
"*!WUcxpSjKyxSGelouhA:matrix.org*". Use that for `MatrixRoom`.
|
||||||
|
|
||||||
|
Finally join the notification user to the room by accepting the invite. Again,
|
||||||
|
this can be done with
|
||||||
|
[client server api](https://matrix.org/docs/guides/client-server-api#joining-a-room-via-an-invite).
|
||||||
|
Make sure to replace room id ("*!*" is escaped with "*%21*") and access token
|
||||||
|
with your data.
|
||||||
|
|
||||||
|
/ tool fetch "https://matrix-client.matrix.org/_matrix/client/r0/rooms/%21WUcxpSjKyxSGelouhA:matrix.org/join?access_token=yt_ZXdvcm0tdGVzdA_NNqUyvKHRhBLZmnzVVSK_0xu6yN" http-method=post http-data="" output=user;
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Usage and invocation
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
There's nothing special to do. Every script or function sending a notification
|
||||||
|
will now send it to your Matrix account.
|
||||||
|
|
||||||
|
See also
|
||||||
|
--------
|
||||||
|
|
||||||
|
* [Send notifications via Telegram](notification-telegram.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
[◀ Go back to main README](../../README.md)
|
||||||
|
[▲ Go back to top](#top)
|
||||||
BIN
doc/mod/notification-telegram.d/newbot.avif
Normal file
|
After Width: | Height: | Size: 35 KiB |
63
doc/mod/notification-telegram.md
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
Send notifications via Telegram
|
||||||
|
===============================
|
||||||
|
|
||||||
|
[◀ Go back to main README](../../README.md)
|
||||||
|
|
||||||
|
> ℹ️️ **Info**: This module can not be used on its own but requires the base
|
||||||
|
> installation. See [main README](../../README.md) for details.
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
This module adds support for sending notifications via
|
||||||
|
[Telegram](https://telegram.org/) via bot api. A queue is used to make sure
|
||||||
|
notifications are not lost on failure but sent later.
|
||||||
|
|
||||||
|
Requirements and installation
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Just install the module:
|
||||||
|
|
||||||
|
$ScriptInstallUpdate mod/notification-telegram;
|
||||||
|
|
||||||
|
Also install Telegram on at least one of your mobile and/or desktop devices
|
||||||
|
and create an account.
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Open Telegram, then start a chat with [BotFather](https://t.me/BotFather) and
|
||||||
|
create your own bot:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Now open a chat with your bot and start it by clicking the `START` button.
|
||||||
|
|
||||||
|
Open just another chat with [GetIDs Bot](https://t.me/getidsbot), again start
|
||||||
|
with the `START` button. It will send you some information, including the
|
||||||
|
`id`, just below `You`.
|
||||||
|
|
||||||
|
Finally edit `global-config-overlay`, add `TelegramTokenId` with the token
|
||||||
|
from *BotFather* and `TelegramChatId` with your id from *GetIDs Bot*. Then
|
||||||
|
reload the configuration.
|
||||||
|
|
||||||
|
### Notifications to a group
|
||||||
|
|
||||||
|
Sending notifications to a group is possible as well. Add your bot and the
|
||||||
|
*GetIDs Bot* to a group, then use the group's id (which starts with a dash)
|
||||||
|
for `TelegramChatId`. Then remove *GetIDs Bot* from group.
|
||||||
|
|
||||||
|
Usage and invocation
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
There's nothing special to do. Every script or function sending a notification
|
||||||
|
will now send it to your Telegram account.
|
||||||
|
|
||||||
|
See also
|
||||||
|
--------
|
||||||
|
|
||||||
|
* [Send notifications via Matrix](notification-matrix.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
[◀ Go back to main README](../../README.md)
|
||||||
|
[▲ Go back to top](#top)
|
||||||
3
doc/mod/scriptrunonce.d/hello-world.rsc
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!rsc by RouterOS
|
||||||
|
|
||||||
|
:put ("Hello World from " . [ / system identity get name ] . "!");
|
||||||
BIN
doc/mod/scriptrunonce.d/scriptrunonce.avif
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
48
doc/mod/scriptrunonce.md
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
Download script and run it once
|
||||||
|
===============================
|
||||||
|
|
||||||
|
[◀ Go back to main README](../../README.md)
|
||||||
|
|
||||||
|
> ℹ️️ **Info**: This module can not be used on its own but requires the base
|
||||||
|
> installation. See [main README](../../README.md) for details.
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
This module adds a function that downloads a script, checks for syntax
|
||||||
|
validity and runs it once.
|
||||||
|
|
||||||
|
Requirements and installation
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Just install the module:
|
||||||
|
|
||||||
|
$ScriptInstallUpdate mod/scriptrunonce;
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The optional configuration goes to `global-config-overlay`.
|
||||||
|
|
||||||
|
* `ScriptRunOnceBaseUrl`: base url, prepended to parameter
|
||||||
|
* `ScriptRunOnceUrlSuffix`: url suffix, appended to parameter
|
||||||
|
|
||||||
|
If the parameter passed to the function is not a complete URL (starting
|
||||||
|
with protocol `ftp://`, `http://`, `https://` or `sftp://`) the values are
|
||||||
|
prepended and appended.
|
||||||
|
|
||||||
|
Usage and invocation
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
The function `$ScriptRunOnce` expects an URL (or name if
|
||||||
|
`ScriptRunOnceBaseUrl` is given) pointing to a script as parameter.
|
||||||
|
|
||||||
|
$ScriptRunOnce https://git.eworm.de/cgit/routeros-scripts/plain/doc/mod/scriptrunonce.d/hello-world.rsc
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Giving multiple scripts is possible, separated by comma.
|
||||||
|
|
||||||
|
---
|
||||||
|
[◀ Go back to main README](../../README.md)
|
||||||
|
[▲ Go back to top](#top)
|
||||||
|
|
@ -3,8 +3,8 @@ Mode button with multiple presses
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Manage DNS and DoH servers from netwatch
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Notify on host up and down
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -38,6 +38,8 @@ The hosts to be checked have to be added to netwatch with specific comment:
|
||||||
|
|
||||||
/ tool netwatch add comment="notify, hostname=example.com" host=[ :resolve "example.com" ];
|
/ tool netwatch add comment="notify, hostname=example.com" host=[ :resolve "example.com" ];
|
||||||
|
|
||||||
|
### Hooks
|
||||||
|
|
||||||
It is possible to run an up hook command (`up-hook`) or down hook command
|
It is possible to run an up hook command (`up-hook`) or down hook command
|
||||||
(`down-hook`) when a notification is triggered. This has to be added in
|
(`down-hook`) when a notification is triggered. This has to be added in
|
||||||
comment, note that some characters need extra escaping:
|
comment, note that some characters need extra escaping:
|
||||||
|
|
@ -48,10 +50,14 @@ Also there is a `pre-down-hook` that fires at two thirds of failed checks
|
||||||
required for the notification. The idea is to fix the issue before a
|
required for the notification. The idea is to fix the issue before a
|
||||||
notification is sent.
|
notification is sent.
|
||||||
|
|
||||||
|
### Count threshould
|
||||||
|
|
||||||
The count threshould (default is 5 checks) is configurable as well:
|
The count threshould (default is 5 checks) is configurable as well:
|
||||||
|
|
||||||
/ tool netwatch add comment="notify, hostname=example.com, count=10" host=104.18.144.11;
|
/ tool netwatch add comment="notify, hostname=example.com, count=10" host=104.18.144.11;
|
||||||
|
|
||||||
|
### Parents & dependencies
|
||||||
|
|
||||||
If the host is behind another checked host add a dependency, this will
|
If the host is behind another checked host add a dependency, this will
|
||||||
suppress notification if the parent host is down:
|
suppress notification if the parent host is down:
|
||||||
|
|
||||||
|
|
@ -61,6 +67,8 @@ suppress notification if the parent host is down:
|
||||||
Note that every configured parent in a chain increases the check count
|
Note that every configured parent in a chain increases the check count
|
||||||
threshould by one.
|
threshould by one.
|
||||||
|
|
||||||
|
### Update from DNS
|
||||||
|
|
||||||
The host address can be updated dynamically. Give extra parameter `resolve`
|
The host address can be updated dynamically. Give extra parameter `resolve`
|
||||||
with a resolvable name:
|
with a resolvable name:
|
||||||
|
|
||||||
|
|
@ -70,7 +78,19 @@ But be warned: Dynamic updates will probably cause issues if the name has
|
||||||
more than one record in dns - a high rate of configuration changes (and flash
|
more than one record in dns - a high rate of configuration changes (and flash
|
||||||
writes) at least.
|
writes) at least.
|
||||||
|
|
||||||
Also notification settings are required for e-mail, matrix and/or telegram.
|
### No notification on host down
|
||||||
|
|
||||||
|
Also suppressing the notification on host down is possible with parameter
|
||||||
|
`no-down-notification`. This may be desired for devices that are usually
|
||||||
|
powered off, but accessibility is of interest.
|
||||||
|
|
||||||
|
/ tool netwatch add comment="notify, hostname=printer, no-down-notification" host=10.0.0.30;
|
||||||
|
|
||||||
|
Go and get your coffee ☕️ before sending the print job.
|
||||||
|
|
||||||
|
Also notification settings are required for e-mail,
|
||||||
|
[matrix](mod/notification-matrix.md) and/or
|
||||||
|
[telegram](mod/notification-telegram.md).
|
||||||
|
|
||||||
Tips & Tricks
|
Tips & Tricks
|
||||||
-------------
|
-------------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Visualize OSPF state via LEDs
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Manage system update
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -41,8 +41,11 @@ See also
|
||||||
--------
|
--------
|
||||||
|
|
||||||
* [Notify on RouterOS update](check-routeros-update.md)
|
* [Notify on RouterOS update](check-routeros-update.md)
|
||||||
|
* [Upload backup to Mikrotik cloud](backup-cloud.md)
|
||||||
* [Send backup via e-mail](backup-email.md)
|
* [Send backup via e-mail](backup-email.md)
|
||||||
|
* [Save configuration to fallback partition](doc/backup-partition.md)
|
||||||
* [Upload backup to server](backup-upload.md)
|
* [Upload backup to server](backup-upload.md)
|
||||||
|
* [Automatically upgrade firmware and reboot](firmware-upgrade-reboot.md)
|
||||||
|
|
||||||
---
|
---
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Run scripts on ppp connection
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Rotate NTP servers
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Act on received SMS
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Forward received SMS
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -31,8 +31,10 @@ Just install the script:
|
||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
Notification settings are required for e-mail, matrix and/or telegram. Also
|
Notification settings are required for e-mail,
|
||||||
you have to enable receiving of SMS:
|
[matrix](mod/notification-matrix.md) and/or
|
||||||
|
[telegram](mod/notification-telegram.md). Also you have to enable receiving
|
||||||
|
of SMS:
|
||||||
|
|
||||||
/ tool sms set receive-enabled=yes;
|
/ tool sms set receive-enabled=yes;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Update GRE configuration with dynamic addresses
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Update tunnelbroker configuration
|
||||||
|
|
||||||
[◀ Go back to main README](../README.md)
|
[◀ Go back to main README](../README.md)
|
||||||
|
|
||||||
🛈 This script can not be used on its own but requires the base installation.
|
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||||
See [main README](../README.md) for details.
|
> installation. See [main README](../README.md) for details.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
#!rsc by RouterOS
|
|
||||||
# dummy for migration
|
|
||||||
41
firmware-upgrade-reboot
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
#!rsc by RouterOS
|
||||||
|
# RouterOS script: firmware-upgrade-reboot
|
||||||
|
# Copyright (c) 2022 Christian Hesse <mail@eworm.de>
|
||||||
|
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
||||||
|
#
|
||||||
|
# install firmware upgrade, and reboot
|
||||||
|
# https://git.eworm.de/cgit/routeros-scripts/about/doc/firmware-upgrade-reboot.md
|
||||||
|
|
||||||
|
:local 0 "firmware-upgrade-reboot";
|
||||||
|
:global GlobalFunctionsReady;
|
||||||
|
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||||
|
|
||||||
|
:global LogPrintExit2;
|
||||||
|
:global VersionToNum;
|
||||||
|
|
||||||
|
:local RouterBoard [ / system routerboard get ];
|
||||||
|
:if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={
|
||||||
|
$LogPrintExit2 info $0 ("Firmware is already up to date.") true;
|
||||||
|
}
|
||||||
|
:if ([ $VersionToNum ($RouterBoard->"current-firmware") ] > [ $VersionToNum ($RouterBoard->"upgrade-firmware") ]) do={
|
||||||
|
$LogPrintExit2 info $0 ("Different firmware version is available, but it is a downgrade. Ignoring.") true;
|
||||||
|
}
|
||||||
|
|
||||||
|
:if ([ / system routerboard settings get auto-upgrade ] = false) do={
|
||||||
|
$LogPrintExit2 info $0 ("Firmware version " . $RouterBoard->"upgrade-firmware" . \
|
||||||
|
" is available, upgrading.") false;
|
||||||
|
/ system routerboard upgrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
:while ([ :len [ / log find where topics=({"system";"info";"critical"}) \
|
||||||
|
message="Firmware upgraded successfully, please reboot for changes to take effect!" ] ] = 0) do={
|
||||||
|
:delay 1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
:local Uptime [ / system resource get uptime ];
|
||||||
|
:if ($Uptime < 1m) do={
|
||||||
|
:delay $Uptime;
|
||||||
|
}
|
||||||
|
|
||||||
|
$LogPrintExit2 info $0 ("Firmware upgrade successful, rebooting.") false;
|
||||||
|
/ system reboot;
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
# Make sure all configuration properties are up to date and this
|
# Make sure all configuration properties are up to date and this
|
||||||
# value is in sync with value in script 'global-functions'!
|
# value is in sync with value in script 'global-functions'!
|
||||||
:global GlobalConfigVersion 74;
|
:global GlobalConfigVersion 80;
|
||||||
|
|
||||||
# This is used for DNS and backup file.
|
# This is used for DNS and backup file.
|
||||||
:global Domain "example.com";
|
:global Domain "example.com";
|
||||||
|
|
@ -159,14 +159,11 @@
|
||||||
# alternative urls - main: stable code - next: currently in development
|
# alternative urls - main: stable code - next: currently in development
|
||||||
#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/main/";
|
#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/main/";
|
||||||
#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/next/";
|
#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/next/";
|
||||||
#:global ScriptUpdatesBaseUrl "https://raw.githubusercontent.com/eworm-de/routeros-scripts/routeros-v7/";
|
|
||||||
#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/main/";
|
#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/main/";
|
||||||
#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/next/";
|
#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/next/";
|
||||||
#:global ScriptUpdatesBaseUrl "https://gitlab.com/eworm-de/routeros-scripts/raw/routeros-v7/";
|
|
||||||
:global ScriptUpdatesUrlSuffix "";
|
:global ScriptUpdatesUrlSuffix "";
|
||||||
# use next or routeros-v7 branch with default url (git.eworm.de)
|
# use next branch with default url (git.eworm.de)
|
||||||
#:global ScriptUpdatesUrlSuffix "\?h=next";
|
#:global ScriptUpdatesUrlSuffix "\?h=next";
|
||||||
#:global ScriptUpdatesUrlSuffix "\?h=routeros-v7";
|
|
||||||
|
|
||||||
# Use this for defaults with $ScriptRunOnce
|
# Use this for defaults with $ScriptRunOnce
|
||||||
# Install module with:
|
# Install module with:
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,10 @@
|
||||||
# Make sure all configuration properties are up to date and this
|
# Make sure all configuration properties are up to date and this
|
||||||
# value is in sync with value in script 'global-functions'!
|
# value is in sync with value in script 'global-functions'!
|
||||||
# Comment or remove to disable news and change notifications.
|
# Comment or remove to disable news and change notifications.
|
||||||
:global GlobalConfigVersion 74;
|
:global GlobalConfigVersion 79;
|
||||||
|
|
||||||
|
# Use branch routeros-v6 with RouterOS v6:
|
||||||
|
:global ScriptUpdatesUrlSuffix "\?h=routeros-v6";
|
||||||
|
|
||||||
# Copy configuration from global-config here and modify it.
|
# Copy configuration from global-config here and modify it.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,11 +73,17 @@
|
||||||
67="Moved modules to directory with shorter name.";
|
67="Moved modules to directory with shorter name.";
|
||||||
68="Reintroduced 'global-wait' for functions in scheduler.";
|
68="Reintroduced 'global-wait' for functions in scheduler.";
|
||||||
69="Support hard lower limit for voltage in 'check-health'.";
|
69="Support hard lower limit for voltage in 'check-health'.";
|
||||||
70="MikroTik started pushing RouterOS v7. Changes are required if you run it, see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v7";
|
70="MikroTik started pushing RouterOS v7. Changes are required if you run it, see https://git.eworm.de/cgit/routeros-scripts/about/#requirements";
|
||||||
71="MikroTik is pushing RouterOS v7 even more, in parallel branches. If you want to keep RouterOS v6 for some time see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v6";
|
71="MikroTik is pushing RouterOS v7 even more, in parallel branches. If you want to keep RouterOS v6 for some time see https://git.eworm.de/cgit/routeros-scripts/about/#requirements";
|
||||||
72="Introduced new script 'netwatch-dns' to manage DNS and DoH servers from netwatch.";
|
72="Introduced new script 'netwatch-dns' to manage DNS and DoH servers from netwatch.";
|
||||||
73="Renamed backup scripts ('cloud-backup' -> 'backup-cloud', 'email-backup' -> 'backup-email', 'upload-backup' -> 'backup-upload').";
|
73="Renamed backup scripts ('cloud-backup' -> 'backup-cloud', 'email-backup' -> 'backup-email', 'upload-backup' -> 'backup-upload').";
|
||||||
74="Extended 'hotspot-to-wpa', it can now read additional configuration from templates and hotspot users.";
|
74="Extended 'hotspot-to-wpa', it can now read additional configuration from templates and hotspot users.";
|
||||||
|
75="You are using the branch 'routeros-v6', well done.";
|
||||||
|
76="Added an option to suppress notifications on host down with 'netwatch-notify'.";
|
||||||
|
77="Introduced new script 'firmware-upgrade-reboot'. Handle with care!";
|
||||||
|
78="New documentation is online for notifications via Telegram & Matrix, variable inspection, ip address calculation and running scripts once.";
|
||||||
|
79="Introduced new script 'backup-partition' to save configuration to fallback partition.";
|
||||||
|
80="The 'routeros-v6' branch entered soft freeze state and will receive important updates only. Happy to welcome you in 'main' branch once moving to RouterOS v7!";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Migration steps to be applied on script updates
|
# Migration steps to be applied on script updates
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,10 @@
|
||||||
# global functions
|
# global functions
|
||||||
# https://git.eworm.de/cgit/routeros-scripts/about/
|
# https://git.eworm.de/cgit/routeros-scripts/about/
|
||||||
|
|
||||||
|
:local 0 "global-functions";
|
||||||
|
|
||||||
# expected configuration version
|
# expected configuration version
|
||||||
:global ExpectedConfigVersion 74;
|
:global ExpectedConfigVersion 80;
|
||||||
|
|
||||||
# global variables not to be changed by user
|
# global variables not to be changed by user
|
||||||
:global GlobalFunctionsReady false;
|
:global GlobalFunctionsReady false;
|
||||||
|
|
@ -38,6 +40,7 @@
|
||||||
:global ParseKeyValueStore;
|
:global ParseKeyValueStore;
|
||||||
:global QuotedPrintable;
|
:global QuotedPrintable;
|
||||||
:global RandomDelay;
|
:global RandomDelay;
|
||||||
|
:global Read;
|
||||||
:global RequiredRouterOS;
|
:global RequiredRouterOS;
|
||||||
:global ScriptFromTerminal;
|
:global ScriptFromTerminal;
|
||||||
:global ScriptInstallUpdate;
|
:global ScriptInstallUpdate;
|
||||||
|
|
@ -221,7 +224,8 @@
|
||||||
[ $IfThenElse ([ :typeof ($Update->"latest-version") ] != "nothing" && \
|
[ $IfThenElse ([ :typeof ($Update->"latest-version") ] != "nothing" && \
|
||||||
$Update->"installed-version" != $Update->"latest-version") \
|
$Update->"installed-version" != $Update->"latest-version") \
|
||||||
("\n Available: " . $Update->"latest-version") ] . \
|
("\n Available: " . $Update->"latest-version") ] . \
|
||||||
[ $IfThenElse ($RouterBoard->"routerboard" = true) \
|
[ $IfThenElse ($RouterBoard->"routerboard" = true && \
|
||||||
|
$RouterBoard->"current-firmware" != $RouterBoard->"upgrade-firmware") \
|
||||||
("\n Firmware: " . $RouterBoard->"current-firmware") ] . \
|
("\n Firmware: " . $RouterBoard->"current-firmware") ] . \
|
||||||
"\nRouterOS-Scripts:" . \
|
"\nRouterOS-Scripts:" . \
|
||||||
"\n Current: " . $GlobalConfigVersion . \
|
"\n Current: " . $GlobalConfigVersion . \
|
||||||
|
|
@ -252,6 +256,7 @@
|
||||||
:global CleanFilePath;
|
:global CleanFilePath;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global MkDir;
|
:global MkDir;
|
||||||
|
:global VersionToNum;
|
||||||
:global WaitForFile;
|
:global WaitForFile;
|
||||||
|
|
||||||
:if ([ :len $PkgName ] = 0) do={ :return false; }
|
:if ([ :len $PkgName ] = 0) do={ :return false; }
|
||||||
|
|
@ -259,6 +264,9 @@
|
||||||
:if ([ :len $PkgArch ] = 0) do={ :set PkgArch [ / system resource get architecture-name ]; }
|
:if ([ :len $PkgArch ] = 0) do={ :set PkgArch [ / system resource get architecture-name ]; }
|
||||||
|
|
||||||
:local PkgFile ($PkgName . "-" . $PkgVer . "-" . $PkgArch . ".npk");
|
:local PkgFile ($PkgName . "-" . $PkgVer . "-" . $PkgArch . ".npk");
|
||||||
|
:if ([ $VersionToNum $PkgVer ] < [ $VersionToNum "7.0" ] && $PkgName = "routeros") do={
|
||||||
|
:set PkgFile ($PkgName . "-" . $PkgArch . "-" . $PkgVer . ".npk");
|
||||||
|
}
|
||||||
:if ($PkgArch = "x86_64" || $PkgName ~ "^routeros-") do={
|
:if ($PkgArch = "x86_64" || $PkgName ~ "^routeros-") do={
|
||||||
:set PkgFile ($PkgName . "-" . $PkgVer . ".npk");
|
:set PkgFile ($PkgName . "-" . $PkgVer . ".npk");
|
||||||
}
|
}
|
||||||
|
|
@ -278,13 +286,13 @@
|
||||||
$LogPrintExit2 error $0 ("Downloading required certificate failed.") true;
|
$LogPrintExit2 error $0 ("Downloading required certificate failed.") true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:local Url ("https://upgrade.mikrotik.com/routeros/" . $PkgVer . "/" . $PkgFile);
|
||||||
$LogPrintExit2 info $0 ("Downloading package file '" . $PkgName . "'...") false;
|
$LogPrintExit2 info $0 ("Downloading package file '" . $PkgName . "'...") false;
|
||||||
|
$LogPrintExit2 debug $0 ("... from url: " . $Url) false;
|
||||||
:local Retry 3;
|
:local Retry 3;
|
||||||
:while ($Retry > 0) do={
|
:while ($Retry > 0) do={
|
||||||
:do {
|
:do {
|
||||||
/ tool fetch check-certificate=yes-without-crl \
|
/ tool fetch check-certificate=yes-without-crl $Url dst-path=$PkgDest;
|
||||||
("https://upgrade.mikrotik.com/routeros/" . $PkgVer . "/" . $PkgFile) \
|
|
||||||
dst-path=$PkgDest;
|
|
||||||
$WaitForFile $PkgDest;
|
$WaitForFile $PkgDest;
|
||||||
|
|
||||||
:if ([ / file get [ find where name=$PkgDest ] type ] = "package") do={
|
:if ([ / file get [ find where name=$PkgDest ] type ] = "package") do={
|
||||||
|
|
@ -353,6 +361,7 @@
|
||||||
:foreach Id,Message in=$EmailQueue do={
|
:foreach Id,Message in=$EmailQueue do={
|
||||||
:if ([ :typeof $Message ] = "array" ) do={
|
:if ([ :typeof $Message ] = "array" ) do={
|
||||||
:local Attach [ $EitherOr ($Message->"attach") "" ];
|
:local Attach [ $EitherOr ($Message->"attach") "" ];
|
||||||
|
:while ([ / tool e-mail get last-status ] = "in-progress") do={ :delay 1s; }
|
||||||
/ tool e-mail send to=($Message->"to") cc=($Message->"cc") subject=($Message->"subject") \
|
/ tool e-mail send to=($Message->"to") cc=($Message->"cc") subject=($Message->"subject") \
|
||||||
body=($Message->"body") file=$Attach;
|
body=($Message->"body") file=$Attach;
|
||||||
:local Wait true;
|
:local Wait true;
|
||||||
|
|
@ -476,7 +485,7 @@
|
||||||
:return ("\1B[" . $Color->$1 . "m" . $1 . "\1B[0m");
|
:return ("\1B[" . $Color->$1 . "m" . $1 . "\1B[0m");
|
||||||
}
|
}
|
||||||
|
|
||||||
:local Log ($Name . ": " . $Message);
|
:local Log ([ $EitherOr $Name "<unknown>" ] . ": " . $Message);
|
||||||
:if ($Severity ~ ("^(debug|error|info)\$")) do={
|
:if ($Severity ~ ("^(debug|error|info)\$")) do={
|
||||||
:if ($Severity = "debug") do={ :log debug $Log; }
|
:if ($Severity = "debug") do={ :log debug $Log; }
|
||||||
:if ($Severity = "error") do={ :log error $Log; }
|
:if ($Severity = "error") do={ :log error $Log; }
|
||||||
|
|
@ -506,6 +515,10 @@
|
||||||
|
|
||||||
:set Dir [ $CleanFilePath $Dir ];
|
:set Dir [ $CleanFilePath $Dir ];
|
||||||
|
|
||||||
|
:if ($Dir = "") do={
|
||||||
|
:return true;
|
||||||
|
}
|
||||||
|
|
||||||
:if ([ :len [ / file find where name=$Dir type="directory" ] ] = 1) do={
|
:if ([ :len [ / file find where name=$Dir type="directory" ] ] = 1) do={
|
||||||
:return true;
|
:return true;
|
||||||
}
|
}
|
||||||
|
|
@ -630,6 +643,11 @@
|
||||||
:delay ([ $GetRandomNumber $1 ] . [ $EitherOr $2 "s" ]);
|
:delay ([ $GetRandomNumber $1 ] . [ $EitherOr $2 "s" ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# read input from user
|
||||||
|
:set Read do={
|
||||||
|
:return;
|
||||||
|
}
|
||||||
|
|
||||||
# check for required RouterOS version
|
# check for required RouterOS version
|
||||||
:set RequiredRouterOS do={
|
:set RequiredRouterOS do={
|
||||||
:local Caller [ :tostr $1 ];
|
:local Caller [ :tostr $1 ];
|
||||||
|
|
@ -672,7 +690,8 @@
|
||||||
|
|
||||||
# install new scripts, update existing scripts
|
# install new scripts, update existing scripts
|
||||||
:set ScriptInstallUpdate do={
|
:set ScriptInstallUpdate do={
|
||||||
:local Scripts [ :toarray $1 ];
|
:local Scripts [ :toarray $1 ];
|
||||||
|
:local NewComment [ :tostr $2 ];
|
||||||
|
|
||||||
:global ExpectedConfigVersion;
|
:global ExpectedConfigVersion;
|
||||||
:global GlobalConfigVersion;
|
:global GlobalConfigVersion;
|
||||||
|
|
@ -699,7 +718,7 @@
|
||||||
:foreach Script in=$Scripts do={
|
:foreach Script in=$Scripts do={
|
||||||
:if ([ :len [ / system script find where name=$Script ] ] = 0) do={
|
:if ([ :len [ / system script find where name=$Script ] ] = 0) do={
|
||||||
$LogPrintExit2 info $0 ("Adding new script: " . $Script) false;
|
$LogPrintExit2 info $0 ("Adding new script: " . $Script) false;
|
||||||
/ system script add name=$Script source="#!rsc by RouterOS\n";
|
/ system script add name=$Script owner=$Script source="#!rsc by RouterOS\n" comment=$NewComment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -719,28 +738,28 @@
|
||||||
:foreach Scheduler in=[ / system scheduler find where on-event~("\\b" . $ScriptVal->"name" . "\\b") ] do={
|
:foreach Scheduler in=[ / system scheduler find where on-event~("\\b" . $ScriptVal->"name" . "\\b") ] do={
|
||||||
:local SchedulerVal [ / system scheduler get $Scheduler ];
|
:local SchedulerVal [ / system scheduler get $Scheduler ];
|
||||||
:if ($ScriptVal->"policy" != $SchedulerVal->"policy") do={
|
:if ($ScriptVal->"policy" != $SchedulerVal->"policy") do={
|
||||||
$LogPrintExit2 warning $0 ("Policies differ for script " . $ScriptVal->"name" . \
|
$LogPrintExit2 warning $0 ("Policies differ for script '" . $ScriptVal->"name" . \
|
||||||
" and its scheduler " . $SchedulerVal->"name" . "!") false;
|
"' and its scheduler '" . $SchedulerVal->"name" . "'!") false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :len $SourceNew ] = 0 && $ScriptUpdatesFetch = true) do={
|
:if ([ :len $SourceNew ] = 0 && $ScriptUpdatesFetch = true) do={
|
||||||
:local Comment [ $ParseKeyValueStore ($ScriptVal->"comment") ];
|
:local Comment [ $ParseKeyValueStore ($ScriptVal->"comment") ];
|
||||||
:if (!($Comment->"ignore" = true)) do={
|
:if (!($Comment->"ignore" = true)) do={
|
||||||
$LogPrintExit2 debug $0 ("Fetching script from url: " . $ScriptVal->"name") false;
|
|
||||||
:do {
|
:do {
|
||||||
:local BaseUrl $ScriptUpdatesBaseUrl;
|
:local BaseUrl $ScriptUpdatesBaseUrl;
|
||||||
:local UrlSuffix $ScriptUpdatesUrlSuffix;
|
:local UrlSuffix $ScriptUpdatesUrlSuffix;
|
||||||
:if ([ :typeof ($Comment->"base-url") ] = "str") do={ :set BaseUrl ($Comment->"base-url"); }
|
:if ([ :typeof ($Comment->"base-url") ] = "str") do={ :set BaseUrl ($Comment->"base-url"); }
|
||||||
:if ([ :typeof ($Comment->"url-suffix") ] = "str") do={ :set UrlSuffix ($Comment->"url-suffix"); }
|
:if ([ :typeof ($Comment->"url-suffix") ] = "str") do={ :set UrlSuffix ($Comment->"url-suffix"); }
|
||||||
|
:local Url ($BaseUrl . $ScriptVal->"name" . $UrlSuffix);
|
||||||
|
|
||||||
:local Result [ / tool fetch check-certificate=yes-without-crl \
|
$LogPrintExit2 debug $0 ("Fetching script '" . $ScriptVal->"name" . "' from url: " . $Url) false;
|
||||||
($BaseUrl . $ScriptVal->"name" . $UrlSuffix) output=user as-value ];
|
:local Result [ / tool fetch check-certificate=yes-without-crl $Url output=user as-value ];
|
||||||
:if ($Result->"status" = "finished") do={
|
:if ($Result->"status" = "finished") do={
|
||||||
:set SourceNew ($Result->"data");
|
:set SourceNew ($Result->"data");
|
||||||
}
|
}
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit2 warning $0 ("Failed fetching " . $ScriptVal->"name") false;
|
$LogPrintExit2 warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "'!") false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -761,18 +780,18 @@
|
||||||
:set ReloadGlobalFunctions true;
|
:set ReloadGlobalFunctions true;
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 warning $0 ("Syntax validation for script " . $ScriptVal->"name" . \
|
$LogPrintExit2 warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . \
|
||||||
" failed! Ignoring!") false;
|
"' failed! Ignoring!") false;
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 warning $0 ("Looks like new script " . $ScriptVal->"name" . \
|
$LogPrintExit2 warning $0 ("Looks like new script '" . $ScriptVal->"name" . \
|
||||||
" is not valid (missing shebang). Ignoring!") false;
|
"' is not valid (missing shebang). Ignoring!") false;
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 debug $0 ("Script " . $ScriptVal->"name" . " did not change.") false;
|
$LogPrintExit2 debug $0 ("Script '" . $ScriptVal->"name" . "' did not change.") false;
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 debug $0 ("No update for script " . $ScriptVal->"name" . ".") false;
|
$LogPrintExit2 debug $0 ("No update for script '" . $ScriptVal->"name" . "'.") false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -800,11 +819,10 @@
|
||||||
:global GlobalConfigMigration;
|
:global GlobalConfigMigration;
|
||||||
:local ChangeLogCode;
|
:local ChangeLogCode;
|
||||||
|
|
||||||
$LogPrintExit2 debug $0 ("Fetching news, changes and migration.") false;
|
|
||||||
:do {
|
:do {
|
||||||
:local Result [ / tool fetch check-certificate=yes-without-crl \
|
:local Url ($ScriptUpdatesBaseUrl . "global-config.changes" . $ScriptUpdatesUrlSuffix);
|
||||||
($ScriptUpdatesBaseUrl . "global-config.changes" . $ScriptUpdatesUrlSuffix) \
|
$LogPrintExit2 debug $0 ("Fetching news, changes and migration: " . $Url) false;
|
||||||
output=user as-value ];
|
:local Result [ / tool fetch check-certificate=yes-without-crl $Url output=user as-value ];
|
||||||
:if ($Result->"status" = "finished") do={
|
:if ($Result->"status" = "finished") do={
|
||||||
:set ChangeLogCode ($Result->"data");
|
:set ChangeLogCode ($Result->"data");
|
||||||
}
|
}
|
||||||
|
|
@ -1253,16 +1271,24 @@
|
||||||
|
|
||||||
# load modules
|
# load modules
|
||||||
:foreach Script in=[ / system script find where name ~ "^mod/." ] do={
|
:foreach Script in=[ / system script find where name ~ "^mod/." ] do={
|
||||||
/ system script run $Script;
|
:local ScriptVal [ / system script get $Script ];
|
||||||
|
:if ([ $ValidateSyntax ($ScriptVal->"source") ] = true) do={
|
||||||
|
:do {
|
||||||
|
/ system script run $Script;
|
||||||
|
} on-error={
|
||||||
|
$LogPrintExit2 error $0 ("Module '" . $ScriptVal->"name" . "' failed to run.") false;
|
||||||
|
}
|
||||||
|
} else={
|
||||||
|
$LogPrintExit2 error $0 ("Module '" . $ScriptVal->"name" . "' failed syntax validation, skipping.") false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for required RouterOS version
|
# check for required RouterOS version
|
||||||
$RequiredRouterOS "global-functions" "6.47" true;
|
$RequiredRouterOS $0 "6.47" true;
|
||||||
|
|
||||||
# ... and give a hint on RouterOS v7.
|
# ... and give a hint on RouterOS v7.
|
||||||
:if ([ $RequiredRouterOS "global-functions" "7.0" false ] = true) do={
|
:if ([ $RequiredRouterOS $0 "7.0" false ] = true) do={
|
||||||
$LogPrintExit2 warning $0 ("RouterOS v7 brings some incompatible changes. Please switch to branch " . \
|
$LogPrintExit2 warning $0 ("RouterOS v7 brings some incompatible changes. Please switch to main branch!") false;
|
||||||
"'routeros-v7', see https://git.eworm.de/cgit/routeros-scripts/about/#changes-for-routeros-v7") false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# signal we are ready
|
# signal we are ready
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
# Copyright (c) 2020-2022 Christian Hesse <mail@eworm.de>
|
# Copyright (c) 2020-2022 Christian Hesse <mail@eworm.de>
|
||||||
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
||||||
#
|
#
|
||||||
# provides: backup-script
|
|
||||||
#
|
|
||||||
# wait for global-functions to finish
|
# wait for global-functions to finish
|
||||||
# https://git.eworm.de/cgit/routeros-scripts/about/doc/global-wait.md
|
# https://git.eworm.de/cgit/routeros-scripts/about/doc/global-wait.md
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,9 @@
|
||||||
:local MacAddress $"mac-address";
|
:local MacAddress $"mac-address";
|
||||||
:local UserName $username;
|
:local UserName $username;
|
||||||
:local Date [ / system clock get date ];
|
:local Date [ / system clock get date ];
|
||||||
:local Hotspot [ / ip hotspot host get [ find where mac-address=$MacAddress authorized ] server ];
|
|
||||||
:local UserVal [ / ip hotspot user get [ find where name=$UserName ] ];
|
:local UserVal [ / ip hotspot user get [ find where name=$UserName ] ];
|
||||||
|
:local UserInfo [ $ParseKeyValueStore ($UserVal->"comment") ];
|
||||||
|
:local Hotspot [ / ip hotspot host get [ find where mac-address=$MacAddress authorized ] server ];
|
||||||
|
|
||||||
:if ([ :len [ / caps-man access-list find where comment="--- hotspot-to-wpa above ---" disabled ] ] = 0) do={
|
:if ([ :len [ / caps-man access-list find where comment="--- hotspot-to-wpa above ---" disabled ] ] = 0) do={
|
||||||
/ caps-man access-list add comment="--- hotspot-to-wpa above ---" disabled=yes;
|
/ caps-man access-list add comment="--- hotspot-to-wpa above ---" disabled=yes;
|
||||||
|
|
@ -26,18 +27,29 @@
|
||||||
}
|
}
|
||||||
:local PlaceBefore ([ / caps-man access-list find where comment="--- hotspot-to-wpa above ---" disabled ]->0);
|
:local PlaceBefore ([ / caps-man access-list find where comment="--- hotspot-to-wpa above ---" disabled ]->0);
|
||||||
|
|
||||||
|
:if ([ :len [ / caps-man access-list find where \
|
||||||
|
comment=("hotspot-to-wpa template " . $Hotspot) disabled ] ] = 0) do={
|
||||||
|
/ caps-man access-list add comment=("hotspot-to-wpa template " . $Hotspot) disabled=yes place-before=$PlaceBefore;
|
||||||
|
$LogPrintExit2 warning $0 ("Added template in access-list for hotspot '" . $Hotspot . "'.") false;
|
||||||
|
}
|
||||||
|
:local Template [ / caps-man access-list get ([ find where \
|
||||||
|
comment=("hotspot-to-wpa template " . $Hotspot) disabled ]->0) ];
|
||||||
|
|
||||||
|
:if ($Template->"action" = "reject") do={
|
||||||
|
$LogPrintExit2 info $0 ("Ignoring login for hotspot '" . $Hotspot . "'.") true;
|
||||||
|
}
|
||||||
|
|
||||||
|
# allow login page to load
|
||||||
|
:delay 1s;
|
||||||
|
|
||||||
$LogPrintExit2 info $0 ("Adding/updating accesslist entry for mac address " . $MacAddress . \
|
$LogPrintExit2 info $0 ("Adding/updating accesslist entry for mac address " . $MacAddress . \
|
||||||
" (user " . $UserName . ").") false;
|
" (user " . $UserName . ").") false;
|
||||||
|
|
||||||
/ caps-man access-list remove [ find where mac-address=$MacAddress comment~"^hotspot-to-wpa: " ];
|
/ caps-man access-list remove [ find where mac-address=$MacAddress comment~"^hotspot-to-wpa: " ];
|
||||||
/ caps-man access-list add comment=("hotspot-to-wpa: " . $UserName . ", " . $MacAddress . ", " . $Date) \
|
/ caps-man access-list add comment=("hotspot-to-wpa: " . $UserName . ", " . $MacAddress . ", " . $Date) \
|
||||||
mac-address=$MacAddress private-passphrase=($UserVal->"password") ssid-regexp="-wpa\$" place-before=$PlaceBefore;
|
mac-address=$MacAddress private-passphrase=($UserVal->"password") ssid-regexp="-wpa\$" place-before=$PlaceBefore;
|
||||||
|
|
||||||
:local Template [ / caps-man access-list get ([ find where comment=("hotspot-to-wpa template " . $Hotspot) disabled ]->0) ];
|
|
||||||
:local UserInfo [ $ParseKeyValueStore ($UserVal->"comment") ];
|
|
||||||
:local Entry [ / caps-man access-list find where mac-address=$MacAddress \
|
:local Entry [ / caps-man access-list find where mac-address=$MacAddress \
|
||||||
comment=("hotspot-to-wpa: " . $UserName . ", " . $MacAddress . ", " . $Date) ];
|
comment=("hotspot-to-wpa: " . $UserName . ", " . $MacAddress . ", " . $Date) ];
|
||||||
|
|
||||||
:local PrivatePassphrase [ $EitherOr ($UserInfo->"private-passphrase") ($Template->"private-passphrase") ];
|
:local PrivatePassphrase [ $EitherOr ($UserInfo->"private-passphrase") ($Template->"private-passphrase") ];
|
||||||
:if ([ :len $PrivatePassphrase ] > 0) do={
|
:if ([ :len $PrivatePassphrase ] > 0) do={
|
||||||
:if ($PrivatePassphrase = "ignore") do={
|
:if ($PrivatePassphrase = "ignore") do={
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,14 @@ $ScriptLock $0;
|
||||||
:if ($DnsServers != $DnsCurrent) do={
|
:if ($DnsServers != $DnsCurrent) do={
|
||||||
$LogPrintExit2 info $0 ("Updating DNS servers: " . [ :tostr $DnsServers ]) false;
|
$LogPrintExit2 info $0 ("Updating DNS servers: " . [ :tostr $DnsServers ]) false;
|
||||||
/ ip dns set servers=$DnsServers;
|
/ ip dns set servers=$DnsServers;
|
||||||
|
/ ip dns cache flush;
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
:if ([ :len $DnsFallback ] > 0) do={
|
:if ([ :len $DnsFallback ] > 0) do={
|
||||||
:if ($DnsFallback != $DnsCurrent) do={
|
:if ($DnsFallback != $DnsCurrent) do={
|
||||||
$LogPrintExit2 info $0 ("Updating DNS servers to fallback: " . [ :tostr $DnsFallback ]) false;
|
$LogPrintExit2 info $0 ("Updating DNS servers to fallback: " . [ :tostr $DnsFallback ]) false;
|
||||||
/ ip dns set servers=$DnsFallback;
|
/ ip dns set servers=$DnsFallback;
|
||||||
|
/ ip dns cache flush;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -69,10 +71,12 @@ $ScriptLock $0;
|
||||||
:if ($DohServer != $DohCurrent) do={
|
:if ($DohServer != $DohCurrent) do={
|
||||||
$LogPrintExit2 info $0 ("Updating DoH server: " . $DohServer) false;
|
$LogPrintExit2 info $0 ("Updating DoH server: " . $DohServer) false;
|
||||||
/ ip dns set use-doh-server=$DohServer;
|
/ ip dns set use-doh-server=$DohServer;
|
||||||
|
/ ip dns cache flush;
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
:if ($DohCurrent != "") do={
|
:if ($DohCurrent != "") do={
|
||||||
$LogPrintExit2 info $0 ("DoH server (" . $DohCurrent . ") is down, disabling.") false;
|
$LogPrintExit2 info $0 ("DoH server (" . $DohCurrent . ") is down, disabling.") false;
|
||||||
/ ip dns set use-doh-server="";
|
/ ip dns set use-doh-server="";
|
||||||
|
/ ip dns cache flush;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,21 +66,23 @@ $ScriptLock $0;
|
||||||
:set $Metric ($NetwatchNotify->$HostName);
|
:set $Metric ($NetwatchNotify->$HostName);
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :typeof ($HostInfo->"resolve") ] = "str" && [ $DNSIsResolving ] = true) do={
|
:if ([ :typeof ($HostInfo->"resolve") ] = "str") do={
|
||||||
:do {
|
:if ([ $DNSIsResolving ] = true) do={
|
||||||
:local Resolve [ :resolve ($HostInfo->"resolve") ];
|
:do {
|
||||||
:if ($Resolve != $HostVal->"host") do={
|
:local Resolve [ :resolve ($HostInfo->"resolve") ];
|
||||||
$LogPrintExit2 info $0 ("Name '" . $HostInfo->"resolve" . [ $IfThenElse ($HostInfo->"resolve" != \
|
:if ($Resolve != $HostVal->"host") do={
|
||||||
$HostInfo->"hostname") ("' for host '" . $HostInfo->"hostname") "" ] . \
|
$LogPrintExit2 info $0 ("Name '" . $HostInfo->"resolve" . [ $IfThenElse ($HostInfo->"resolve" != \
|
||||||
"' resolves to different address " . $Resolve . ", updating.") false;
|
$HostInfo->"hostname") ("' for host '" . $HostInfo->"hostname") "" ] . \
|
||||||
/ tool netwatch set host=$Resolve $Host;
|
"' resolves to different address " . $Resolve . ", updating.") false;
|
||||||
:set ($Metric->"resolve-failed") false;
|
/ tool netwatch set host=$Resolve $Host;
|
||||||
}
|
:set ($Metric->"resolve-failed") false;
|
||||||
} on-error={
|
}
|
||||||
:if ($Metric->"resolve-failed" != true) do={
|
} on-error={
|
||||||
$LogPrintExit2 warning $0 ("Resolving name '" . $HostInfo->"resolve" . [ $IfThenElse ($HostInfo->"resolve" != \
|
:if ($Metric->"resolve-failed" != true) do={
|
||||||
$HostInfo->"hostname") ("' for host '" . $HostInfo->"hostname") "" ] . "' failed.") false;
|
$LogPrintExit2 warning $0 ("Resolving name '" . $HostInfo->"resolve" . [ $IfThenElse ($HostInfo->"resolve" != \
|
||||||
:set ($Metric->"resolve-failed") true;
|
$HostInfo->"hostname") ("' for host '" . $HostInfo->"hostname") "" ] . "' failed.") false;
|
||||||
|
:set ($Metric->"resolve-failed") true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -122,10 +124,10 @@ $ScriptLock $0;
|
||||||
:set Parent ($NetwatchNotify->$Parent->"parent");
|
:set Parent ($NetwatchNotify->$Parent->"parent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$LogPrintExit2 info $0 ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . \
|
$LogPrintExit2 [ $IfThenElse ($HostInfo->"no-down-notification" != true) info debug ] $0 \
|
||||||
$Metric->"count" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \
|
("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . $Metric->"count" . " checks, " . \
|
||||||
($Metric->"notified" = true) ("already notified.") ($Count - $Metric->"count" . " to go.") ] \
|
[ $IfThenElse ($ParentNotified = false) [ $IfThenElse ($Metric->"notified" = true) ("already notified.") \
|
||||||
("parent host " . $Parent . " is down.") ]) false;
|
($Count - $Metric->"count" . " to go.") ] ("parent host " . $Parent . " is down.") ]) false;
|
||||||
:if ((($Count * 2) - ($Metric->"count" * 3)) / 2 = 0 && [ :typeof ($HostInfo->"pre-down-hook") ] = "str") do={
|
:if ((($Count * 2) - ($Metric->"count" * 3)) / 2 = 0 && [ :typeof ($HostInfo->"pre-down-hook") ] = "str") do={
|
||||||
$NetwatchNotifyHook $HostName "pre-down" ($HostInfo->"pre-down-hook");
|
$NetwatchNotifyHook $HostName "pre-down" ($HostInfo->"pre-down-hook");
|
||||||
}
|
}
|
||||||
|
|
@ -134,9 +136,11 @@ $ScriptLock $0;
|
||||||
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
|
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
|
||||||
:set Message ($Message . "\n\n" . [ $NetwatchNotifyHook $HostName "down" ($HostInfo->"down-hook") ]);
|
:set Message ($Message . "\n\n" . [ $NetwatchNotifyHook $HostName "down" ($HostInfo->"down-hook") ]);
|
||||||
}
|
}
|
||||||
$SendNotification2 ({ origin=$0; \
|
:if ($HostInfo->"no-down-notification" != true) do={
|
||||||
subject=([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down"); \
|
$SendNotification2 ({ origin=$0; \
|
||||||
message=$Message });
|
subject=([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down"); \
|
||||||
|
message=$Message });
|
||||||
|
}
|
||||||
:set ($Metric->"notified") true;
|
:set ($Metric->"notified") true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ $ScriptLock $0;
|
||||||
:if ($NumInstalled > $NumLatest) do={
|
:if ($NumInstalled > $NumLatest) do={
|
||||||
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
||||||
:put "Latest version is older than installed one. Want to downgrade? [y/N]";
|
:put "Latest version is older than installed one. Want to downgrade? [y/N]";
|
||||||
:if (([ :terminal inkey timeout=60 ] % 32) = 25) do={
|
:if (([ / terminal inkey timeout=60 ] % 32) = 25) do={
|
||||||
:set DoDowngrade true;
|
:set DoDowngrade true;
|
||||||
} else={
|
} else={
|
||||||
:put "Canceled...";
|
:put "Canceled...";
|
||||||
|
|
@ -61,7 +61,7 @@ $ScriptLock $0;
|
||||||
$LogPrintExit2 warning $0 ("Running backup script " . $ScriptName . " before update failed!") false;
|
$LogPrintExit2 warning $0 ("Running backup script " . $ScriptName . " before update failed!") false;
|
||||||
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
||||||
:put "Do you want to continue anyway? [y/N]";
|
:put "Do you want to continue anyway? [y/N]";
|
||||||
:if (([ :terminal inkey timeout=60 ] % 32) = 25) do={
|
:if (([ / terminal inkey timeout=60 ] % 32) = 25) do={
|
||||||
$LogPrintExit2 info $0 ("User requested to continue anyway.") false;
|
$LogPrintExit2 info $0 ("User requested to continue anyway.") false;
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 info $0 ("Canceled update...") true;
|
$LogPrintExit2 info $0 ("Canceled update...") true;
|
||||||
|
|
@ -80,7 +80,7 @@ $ScriptLock $0;
|
||||||
|
|
||||||
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
||||||
:put "Do you want to (s)chedule reboot or (r)eboot now? [s/R]";
|
:put "Do you want to (s)chedule reboot or (r)eboot now? [s/R]";
|
||||||
:if (([ :terminal inkey timeout=60 ] % 32) = 19) do={
|
:if (([ / terminal inkey timeout=60 ] % 32) = 19) do={
|
||||||
/ system scheduler add name="reboot-for-update" start-time=03:00:00 interval=1d \
|
/ system scheduler add name="reboot-for-update" start-time=03:00:00 interval=1d \
|
||||||
on-event=(":global RandomDelay; \$RandomDelay 3600; " . \
|
on-event=(":global RandomDelay; \$RandomDelay 3600; " . \
|
||||||
"/ system scheduler remove reboot-for-update; / system reboot;");
|
"/ system scheduler remove reboot-for-update; / system reboot;");
|
||||||
|
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
#!rsc by RouterOS
|
|
||||||
# dummy for migration
|
|
||||||