mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-01-12 20:19:32 +00:00
Compare commits
31 commits
main
...
change-78-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
61 changed files with 516 additions and 147 deletions
|
|
@ -22,6 +22,7 @@ Add yourself to the list,
|
|||
* Abdul Mannan Abbasi
|
||||
* Andrew Cox
|
||||
* Christoph Boss (@Kampfwurst)
|
||||
* Devin Dean (@dd2594gh)
|
||||
* Klaus Michael Rübsam
|
||||
* Linux-Schmie.de Michael Gisbers
|
||||
* Manuel Kuhn
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ Initial commands
|
|||
|
||||
[◀ Go back to main README](README.md)
|
||||
|
||||
These command are inteneded for initial setup. If you are not aware of the
|
||||
procedure please follow [the long way in detail](README.md#the-long-way-in-detail).
|
||||
> ⚠️ **Warning**: These command are inteneded for initial setup. If you are
|
||||
> 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:
|
||||
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -6,7 +6,7 @@ TEMPLATE = $(wildcard *.template)
|
|||
CAPSMAN = $(TEMPLATE:.template=.capsman)
|
||||
LOCAL = $(TEMPLATE:.template=.local)
|
||||
|
||||
MARKDOWN = $(wildcard *.md) $(wildcard doc/*.md)
|
||||
MARKDOWN = $(wildcard *.md doc/*.md doc/mod/*.md)
|
||||
HTML = $(MARKDOWN:.md=.html)
|
||||
|
||||
all: $(CAPSMAN) $(LOCAL) $(HTML)
|
||||
|
|
|
|||
10
README.md
10
README.md
|
|
@ -40,8 +40,8 @@ RouterOS script distribution](https://www.youtube.com/watch?v=B9neG3oAhcY)
|
|||
including demonstation recorded live at [MUM Europe
|
||||
2019](https://mum.mikrotik.com/2019/EU/) in Vienna.
|
||||
|
||||
*Be warned!* Some details changed. So see the presentation, then follow
|
||||
the steps below for up-to-date commands.
|
||||
> ⚠️ **Warning**: Some details changed. So see the presentation, then follow
|
||||
> the steps below for up-to-date commands.
|
||||
|
||||
### The long way in detail
|
||||
|
||||
|
|
@ -204,6 +204,7 @@ Available scripts
|
|||
* [Use wireless network with daily psk](doc/daily-psk.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)
|
||||
* [Automatically upgrade firmware and reboot](doc/firmware-upgrade-reboot.md)
|
||||
* [Wait for global functions und modules](doc/global-wait.md)
|
||||
* [Send GPS position to server](doc/gps-track.md)
|
||||
* [Use WPA2 network with hotspot credentials](doc/hotspot-to-wpa.md)
|
||||
|
|
@ -238,6 +239,11 @@ Available modules
|
|||
|
||||
* [Manage ports in bridge](doc/mod/bridge-port-to.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)
|
||||
|
||||
Contact
|
||||
-------
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ $LogPrintExit2 debug $0 ("Checking for updates...") false;
|
|||
|
||||
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
||||
: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;
|
||||
} else={
|
||||
:put "Canceled...";
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Find and remove access list duplicates
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Upload backup to Mikrotik cloud
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -30,7 +30,9 @@ The configuration goes to `global-config-overlay`, these are the parameters:
|
|||
* `BackupPassword`: password to encrypt the backup with
|
||||
* `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
|
||||
--------------------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Send backup via e-mail
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -12,7 +12,6 @@ Description
|
|||
This script sends binary backup (`/ system backup save`) and complete
|
||||
configuration export (`/ export terse`) via e-mail.
|
||||
|
||||
|
||||
Requirements and installation
|
||||
-----------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Upload backup to server
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -36,7 +36,9 @@ The configuration goes to `global-config-overlay`, these are the parameters:
|
|||
* `BackupUploadUser`: username 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
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Download packages for CAP upgrade from CAPsMAN
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Run rolling CAP upgrades from CAPsMAN
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Renew locally issued certificates
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Renew certificates and notify on expiration
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -27,7 +27,8 @@ Configuration
|
|||
-------------
|
||||
|
||||
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
|
||||
in `global-config-overlay`, these are the parameters:
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Notify about health state
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
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
|
||||
* `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)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Notify on LTE firmware upgrade
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -35,7 +35,9 @@ Just install the script:
|
|||
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
|
||||
--------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Notify on RouterOS update
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -47,6 +47,10 @@ safe versions from a web server. The configuration goes to
|
|||
* `SafeUpdateUrl`: url to check for safe update, the channel (`long-term`,
|
||||
`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
|
||||
--------------------
|
||||
|
||||
|
|
@ -61,6 +65,7 @@ Installing script [packages-update](packages-update.md) gives extra options.
|
|||
See also
|
||||
--------
|
||||
|
||||
* [Automatically upgrade firmware and reboot](firmware-upgrade-reboot.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)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
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
|
||||
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
|
||||
--------------------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Use wireless network with daily psk
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
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";
|
||||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Comment DHCP leases with info from access list
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Create DNS records for DHCP leases
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -1,11 +1,2 @@
|
|||
Send notification with early errors
|
||||
===================================
|
||||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
This script has been replace. Please migrate to
|
||||
This script has been replaced. Please migrate to
|
||||
[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
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)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Send GPS position to server
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Use WPA2 network with hotspot credentials
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Create DNS records for IPSec peers
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Update configuration on IPv6 prefix change
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Run other scripts on DHCP lease
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Forward log messages via notification
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
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
|
||||
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)m.
|
||||
|
||||
---
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
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.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️️ **Info**: This module can not be used on its own but requires the base
|
||||
> installation. See [main README](../../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -77,5 +77,5 @@ See also
|
|||
* [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)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Manage VLANs on bridge ports
|
|||
|
||||
[◀ Go back to main README](../../README.md)
|
||||
|
||||
🛈 This module can not be used on its own but requires the base installation.
|
||||
See [main README](../../README.md) for details.
|
||||
> ℹ️️ **Info**: This module can not be used on its own but requires the base
|
||||
> installation. See [main README](../../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
BIN
doc/mod/inspectvar.d/inspectvar.avif
Normal file
BIN
doc/mod/inspectvar.d/inspectvar.avif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
33
doc/mod/inspectvar.md
Normal file
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
BIN
doc/mod/ipcalc.d/ipcalc.avif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
doc/mod/ipcalc.d/ipcalcreturn.avif
Normal file
BIN
doc/mod/ipcalc.d/ipcalcreturn.avif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
53
doc/mod/ipcalc.md
Normal file
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)
|
||||
45
doc/mod/notification-matrix.md
Normal file
45
doc/mod/notification-matrix.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
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 and create an account.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
Edit `global-config-overlay`, add `MatrixHomeServer`, `MatrixAccessToken` and
|
||||
`MatrixRoom`. Then reload the configuration.
|
||||
|
||||
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
BIN
doc/mod/notification-telegram.d/newbot.avif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
63
doc/mod/notification-telegram.md
Normal file
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
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
BIN
doc/mod/scriptrunonce.d/scriptrunonce.avif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
35
doc/mod/scriptrunonce.md
Normal file
35
doc/mod/scriptrunonce.md
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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;
|
||||
|
||||
Usage and invocation
|
||||
--------------------
|
||||
|
||||
The function `$ScriptRunOnce` expects an url 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)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Manage DNS and DoH servers from netwatch
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Notify on host up and down
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
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" ];
|
||||
|
||||
### Hooks
|
||||
|
||||
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
|
||||
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
|
||||
notification is sent.
|
||||
|
||||
### Count threshould
|
||||
|
||||
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;
|
||||
|
||||
### Parents & dependencies
|
||||
|
||||
If the host is behind another checked host add a dependency, this will
|
||||
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
|
||||
threshould by one.
|
||||
|
||||
### Update from DNS
|
||||
|
||||
The host address can be updated dynamically. Give extra parameter `resolve`
|
||||
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
|
||||
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
|
||||
-------------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Visualize OSPF state via LEDs
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Manage system update
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -41,8 +41,10 @@ See also
|
|||
--------
|
||||
|
||||
* [Notify on RouterOS update](check-routeros-update.md)
|
||||
* [Upload backup to Mikrotik cloud](backup-cloud.md)
|
||||
* [Send backup via e-mail](backup-email.md)
|
||||
* [Upload backup to server](backup-upload.md)
|
||||
* [Automatically upgrade firmware and reboot](firmware-upgrade-reboot.md)
|
||||
|
||||
---
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Run scripts on ppp connection
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Rotate NTP servers
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Act on received SMS
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Forward received SMS
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -31,8 +31,10 @@ Just install the script:
|
|||
Configuration
|
||||
-------------
|
||||
|
||||
Notification settings are required for e-mail, matrix and/or telegram. Also
|
||||
you have to enable receiving of SMS:
|
||||
Notification settings are required for e-mail,
|
||||
[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;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Update GRE configuration with dynamic addresses
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Update tunnelbroker configuration
|
|||
|
||||
[◀ Go back to main README](../README.md)
|
||||
|
||||
🛈 This script can not be used on its own but requires the base installation.
|
||||
See [main README](../README.md) for details.
|
||||
> ℹ️ **Info**: This script can not be used on its own but requires the base
|
||||
> installation. See [main README](../README.md) for details.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
37
firmware-upgrade-reboot
Normal file
37
firmware-upgrade-reboot
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!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;
|
||||
|
||||
:local RouterBoard [ / system routerboard get ];
|
||||
:if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={
|
||||
$LogPrintExit2 info $0 ("Firmware is already up to date.") 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
|
||||
# value is in sync with value in script 'global-functions'!
|
||||
:global GlobalConfigVersion 74;
|
||||
:global GlobalConfigVersion 78;
|
||||
|
||||
# This is used for DNS and backup file.
|
||||
:global Domain "example.com";
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@
|
|||
# Make sure all configuration properties are up to date and this
|
||||
# value is in sync with value in script 'global-functions'!
|
||||
# Comment or remove to disable news and change notifications.
|
||||
:global GlobalConfigVersion 74;
|
||||
:global GlobalConfigVersion 78;
|
||||
|
||||
# Use branch routeros-v6 with RouterOS v6:
|
||||
:global ScriptUpdatesUrlSuffix "\?h=routeros-v6";
|
||||
|
||||
# Copy configuration from global-config here and modify it.
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,10 @@
|
|||
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').";
|
||||
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.";
|
||||
};
|
||||
|
||||
# Migration steps to be applied on script updates
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
# https://git.eworm.de/cgit/routeros-scripts/about/
|
||||
|
||||
# expected configuration version
|
||||
:global ExpectedConfigVersion 74;
|
||||
:global ExpectedConfigVersion 78;
|
||||
|
||||
# global variables not to be changed by user
|
||||
:global GlobalFunctionsReady false;
|
||||
|
|
@ -252,6 +252,7 @@
|
|||
:global CleanFilePath;
|
||||
:global LogPrintExit2;
|
||||
:global MkDir;
|
||||
:global VersionToNum;
|
||||
:global WaitForFile;
|
||||
|
||||
:if ([ :len $PkgName ] = 0) do={ :return false; }
|
||||
|
|
@ -259,6 +260,9 @@
|
|||
:if ([ :len $PkgArch ] = 0) do={ :set PkgArch [ / system resource get architecture-name ]; }
|
||||
|
||||
: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={
|
||||
:set PkgFile ($PkgName . "-" . $PkgVer . ".npk");
|
||||
}
|
||||
|
|
@ -278,13 +282,13 @@
|
|||
$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 debug $0 ("... from url: " . $Url) false;
|
||||
:local Retry 3;
|
||||
:while ($Retry > 0) do={
|
||||
:do {
|
||||
/ tool fetch check-certificate=yes-without-crl \
|
||||
("https://upgrade.mikrotik.com/routeros/" . $PkgVer . "/" . $PkgFile) \
|
||||
dst-path=$PkgDest;
|
||||
/ tool fetch check-certificate=yes-without-crl $Url dst-path=$PkgDest;
|
||||
$WaitForFile $PkgDest;
|
||||
|
||||
:if ([ / file get [ find where name=$PkgDest ] type ] = "package") do={
|
||||
|
|
@ -506,6 +510,10 @@
|
|||
|
||||
:set Dir [ $CleanFilePath $Dir ];
|
||||
|
||||
:if ($Dir = "") do={
|
||||
:return true;
|
||||
}
|
||||
|
||||
:if ([ :len [ / file find where name=$Dir type="directory" ] ] = 1) do={
|
||||
:return true;
|
||||
}
|
||||
|
|
@ -719,28 +727,28 @@
|
|||
:foreach Scheduler in=[ / system scheduler find where on-event~("\\b" . $ScriptVal->"name" . "\\b") ] do={
|
||||
:local SchedulerVal [ / system scheduler get $Scheduler ];
|
||||
:if ($ScriptVal->"policy" != $SchedulerVal->"policy") do={
|
||||
$LogPrintExit2 warning $0 ("Policies differ for script " . $ScriptVal->"name" . \
|
||||
" and its scheduler " . $SchedulerVal->"name" . "!") false;
|
||||
$LogPrintExit2 warning $0 ("Policies differ for script '" . $ScriptVal->"name" . \
|
||||
"' and its scheduler '" . $SchedulerVal->"name" . "'!") false;
|
||||
}
|
||||
}
|
||||
|
||||
:if ([ :len $SourceNew ] = 0 && $ScriptUpdatesFetch = true) do={
|
||||
:local Comment [ $ParseKeyValueStore ($ScriptVal->"comment") ];
|
||||
:if (!($Comment->"ignore" = true)) do={
|
||||
$LogPrintExit2 debug $0 ("Fetching script from url: " . $ScriptVal->"name") false;
|
||||
:do {
|
||||
:local BaseUrl $ScriptUpdatesBaseUrl;
|
||||
:local UrlSuffix $ScriptUpdatesUrlSuffix;
|
||||
:if ([ :typeof ($Comment->"base-url") ] = "str") do={ :set BaseUrl ($Comment->"base-url"); }
|
||||
: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 \
|
||||
($BaseUrl . $ScriptVal->"name" . $UrlSuffix) output=user as-value ];
|
||||
$LogPrintExit2 debug $0 ("Fetching script '" . $ScriptVal->"name" . "' from url: " . $Url) false;
|
||||
:local Result [ / tool fetch check-certificate=yes-without-crl $Url output=user as-value ];
|
||||
:if ($Result->"status" = "finished") do={
|
||||
:set SourceNew ($Result->"data");
|
||||
}
|
||||
} on-error={
|
||||
$LogPrintExit2 warning $0 ("Failed fetching " . $ScriptVal->"name") false;
|
||||
$LogPrintExit2 warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "'!") false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -761,18 +769,18 @@
|
|||
:set ReloadGlobalFunctions true;
|
||||
}
|
||||
} else={
|
||||
$LogPrintExit2 warning $0 ("Syntax validation for script " . $ScriptVal->"name" . \
|
||||
" failed! Ignoring!") false;
|
||||
$LogPrintExit2 warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . \
|
||||
"' failed! Ignoring!") false;
|
||||
}
|
||||
} else={
|
||||
$LogPrintExit2 warning $0 ("Looks like new script " . $ScriptVal->"name" . \
|
||||
" is not valid (missing shebang). Ignoring!") false;
|
||||
$LogPrintExit2 warning $0 ("Looks like new script '" . $ScriptVal->"name" . \
|
||||
"' is not valid (missing shebang). Ignoring!") false;
|
||||
}
|
||||
} else={
|
||||
$LogPrintExit2 debug $0 ("Script " . $ScriptVal->"name" . " did not change.") false;
|
||||
$LogPrintExit2 debug $0 ("Script '" . $ScriptVal->"name" . "' did not change.") false;
|
||||
}
|
||||
} else={
|
||||
$LogPrintExit2 debug $0 ("No update for script " . $ScriptVal->"name" . ".") false;
|
||||
$LogPrintExit2 debug $0 ("No update for script '" . $ScriptVal->"name" . "'.") false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -800,11 +808,10 @@
|
|||
:global GlobalConfigMigration;
|
||||
:local ChangeLogCode;
|
||||
|
||||
$LogPrintExit2 debug $0 ("Fetching news, changes and migration.") false;
|
||||
:do {
|
||||
:local Result [ / tool fetch check-certificate=yes-without-crl \
|
||||
($ScriptUpdatesBaseUrl . "global-config.changes" . $ScriptUpdatesUrlSuffix) \
|
||||
output=user as-value ];
|
||||
:local Url ($ScriptUpdatesBaseUrl . "global-config.changes" . $ScriptUpdatesUrlSuffix);
|
||||
$LogPrintExit2 debug $0 ("Fetching news, changes and migration: " . $Url) false;
|
||||
:local Result [ / tool fetch check-certificate=yes-without-crl $Url output=user as-value ];
|
||||
:if ($Result->"status" = "finished") do={
|
||||
:set ChangeLogCode ($Result->"data");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,14 @@ $ScriptLock $0;
|
|||
:if ($DnsServers != $DnsCurrent) do={
|
||||
$LogPrintExit2 info $0 ("Updating DNS servers: " . [ :tostr $DnsServers ]) false;
|
||||
/ ip dns set servers=$DnsServers;
|
||||
/ ip dns cache flush;
|
||||
}
|
||||
} else={
|
||||
:if ([ :len $DnsFallback ] > 0) do={
|
||||
:if ($DnsFallback != $DnsCurrent) do={
|
||||
$LogPrintExit2 info $0 ("Updating DNS servers to fallback: " . [ :tostr $DnsFallback ]) false;
|
||||
/ ip dns set servers=$DnsFallback;
|
||||
/ ip dns cache flush;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -69,10 +71,12 @@ $ScriptLock $0;
|
|||
:if ($DohServer != $DohCurrent) do={
|
||||
$LogPrintExit2 info $0 ("Updating DoH server: " . $DohServer) false;
|
||||
/ ip dns set use-doh-server=$DohServer;
|
||||
/ ip dns cache flush;
|
||||
}
|
||||
} else={
|
||||
:if ($DohCurrent != "") do={
|
||||
$LogPrintExit2 info $0 ("DoH server (" . $DohCurrent . ") is down, disabling.") false;
|
||||
/ ip dns set use-doh-server="";
|
||||
/ ip dns cache flush;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,21 +66,23 @@ $ScriptLock $0;
|
|||
:set $Metric ($NetwatchNotify->$HostName);
|
||||
}
|
||||
|
||||
:if ([ :typeof ($HostInfo->"resolve") ] = "str" && [ $DNSIsResolving ] = true) do={
|
||||
:do {
|
||||
:local Resolve [ :resolve ($HostInfo->"resolve") ];
|
||||
:if ($Resolve != $HostVal->"host") do={
|
||||
$LogPrintExit2 info $0 ("Name '" . $HostInfo->"resolve" . [ $IfThenElse ($HostInfo->"resolve" != \
|
||||
$HostInfo->"hostname") ("' for host '" . $HostInfo->"hostname") "" ] . \
|
||||
"' resolves to different address " . $Resolve . ", updating.") false;
|
||||
/ tool netwatch set host=$Resolve $Host;
|
||||
:set ($Metric->"resolve-failed") false;
|
||||
}
|
||||
} on-error={
|
||||
:if ($Metric->"resolve-failed" != true) do={
|
||||
$LogPrintExit2 warning $0 ("Resolving name '" . $HostInfo->"resolve" . [ $IfThenElse ($HostInfo->"resolve" != \
|
||||
$HostInfo->"hostname") ("' for host '" . $HostInfo->"hostname") "" ] . "' failed.") false;
|
||||
:set ($Metric->"resolve-failed") true;
|
||||
:if ([ :typeof ($HostInfo->"resolve") ] = "str") do={
|
||||
:if ([ $DNSIsResolving ] = true) do={
|
||||
:do {
|
||||
:local Resolve [ :resolve ($HostInfo->"resolve") ];
|
||||
:if ($Resolve != $HostVal->"host") do={
|
||||
$LogPrintExit2 info $0 ("Name '" . $HostInfo->"resolve" . [ $IfThenElse ($HostInfo->"resolve" != \
|
||||
$HostInfo->"hostname") ("' for host '" . $HostInfo->"hostname") "" ] . \
|
||||
"' resolves to different address " . $Resolve . ", updating.") false;
|
||||
/ tool netwatch set host=$Resolve $Host;
|
||||
:set ($Metric->"resolve-failed") false;
|
||||
}
|
||||
} on-error={
|
||||
:if ($Metric->"resolve-failed" != true) do={
|
||||
$LogPrintExit2 warning $0 ("Resolving name '" . $HostInfo->"resolve" . [ $IfThenElse ($HostInfo->"resolve" != \
|
||||
$HostInfo->"hostname") ("' for host '" . $HostInfo->"hostname") "" ] . "' failed.") false;
|
||||
:set ($Metric->"resolve-failed") true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -122,10 +124,10 @@ $ScriptLock $0;
|
|||
:set Parent ($NetwatchNotify->$Parent->"parent");
|
||||
}
|
||||
}
|
||||
$LogPrintExit2 info $0 ("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . \
|
||||
$Metric->"count" . " checks, " . [ $IfThenElse ($ParentNotified = false) [ $IfThenElse \
|
||||
($Metric->"notified" = true) ("already notified.") ($Count - $Metric->"count" . " to go.") ] \
|
||||
("parent host " . $Parent . " is down.") ]) false;
|
||||
$LogPrintExit2 [ $IfThenElse ($HostInfo->"no-down-notification" != true) info debug ] $0 \
|
||||
("Host " . $HostName . " (" . $HostVal->"host" . ") is down for " . $Metric->"count" . " checks, " . \
|
||||
[ $IfThenElse ($ParentNotified = false) [ $IfThenElse ($Metric->"notified" = true) ("already notified.") \
|
||||
($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={
|
||||
$NetwatchNotifyHook $HostName "pre-down" ($HostInfo->"pre-down-hook");
|
||||
}
|
||||
|
|
@ -134,9 +136,11 @@ $ScriptLock $0;
|
|||
:if ([ :typeof ($HostInfo->"down-hook") ] = "str") do={
|
||||
:set Message ($Message . "\n\n" . [ $NetwatchNotifyHook $HostName "down" ($HostInfo->"down-hook") ]);
|
||||
}
|
||||
$SendNotification2 ({ origin=$0; \
|
||||
subject=([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down"); \
|
||||
message=$Message });
|
||||
:if ($HostInfo->"no-down-notification" != true) do={
|
||||
$SendNotification2 ({ origin=$0; \
|
||||
subject=([ $SymbolForNotification "cross-mark" ] . "Netwatch Notify: " . $HostName . " down"); \
|
||||
message=$Message });
|
||||
}
|
||||
:set ($Metric->"notified") true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ $ScriptLock $0;
|
|||
:if ($NumInstalled > $NumLatest) do={
|
||||
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
||||
: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;
|
||||
} else={
|
||||
:put "Canceled...";
|
||||
|
|
@ -61,7 +61,7 @@ $ScriptLock $0;
|
|||
$LogPrintExit2 warning $0 ("Running backup script " . $ScriptName . " before update failed!") false;
|
||||
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
||||
: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;
|
||||
} else={
|
||||
$LogPrintExit2 info $0 ("Canceled update...") true;
|
||||
|
|
@ -80,7 +80,7 @@ $ScriptLock $0;
|
|||
|
||||
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
||||
: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 \
|
||||
on-event=(":global RandomDelay; \$RandomDelay 3600; " . \
|
||||
"/ system scheduler remove reboot-for-update; / system reboot;");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue