Commit graph

206 commits

Author SHA1 Message Date
Christian Hesse
2c92c78b46 global-functions: $ScriptInstallUpdate: also show commit info 2025-02-17 13:55:44 +01:00
Christian Hesse
75633872aa global-functions: $DeviceInfo: also show commit info 2025-02-17 13:55:36 +01:00
Christian Hesse
dafcc1a0cb global-functions: $RmFile: fix type safeguard
Ups... 🫣
The type is not just literal 'file' - but what ever type the file is,
like 'backup', 'package', 'script', '.conf file', ...

So let's match those types we do *not* want to remove.

Fixes: https://github.com/eworm-de/routeros-scripts/issues/90
2025-02-13 17:58:48 +01:00
Christian Hesse
0199ea8884 global-functions: $ScriptInstallUpdate: show commit id (if available) 2025-02-13 09:50:22 +01:00
Christian Hesse
584e507fd1 global-functions: $DeviceInfo: show commit id (if available) 2025-02-13 09:03:05 +01:00
Christian Hesse
df631b987d fw-addr-lists: add a collective list in default configuration 2025-02-12 17:40:27 +01:00
Christian Hesse
c8759381e9 global-functions: $WaitForFile: check that we can get properties
Looks like RouterOS 7.18beta2 brings more breakage. Having a file
available in listing is just the first step now. We also need to make
sure that the file properties are accessible... 🤪

I have seen this taking several tens of seconds at least... 🤪🤪 So
let's just try until we have properties available, or the file vanishes.

Reported as SUP-179200. 🤞
2025-02-12 10:49:38 +01:00
Christian Hesse
e1c561dd91 global-functions: $MkDir: add debug output 2025-02-11 14:56:43 +01:00
Christian Hesse
f5f00b70e3 global-functions: $MkDir: use $RmDir 2025-02-10 15:23:50 +01:00
Christian Hesse
4760515add global-functions: $FetchHuge: use $RmDir 2025-02-10 15:23:50 +01:00
Christian Hesse
d19b90df08 global-functions: $FetchHuge: use $RmFile 2025-02-10 15:23:50 +01:00
Christian Hesse
ea8ec6b580 global-functions: $DownloadPackage: use $RmFile 2025-02-10 15:23:50 +01:00
Christian Hesse
dbdf295244 global-functions: $CertificateDownload: use $RmFile 2025-02-10 15:23:50 +01:00
Christian Hesse
82020ddd73 global-functions: $RmDir: fail on wrong type 2025-02-10 15:23:50 +01:00
Christian Hesse
a8e5b5226b global-functions: $RmFile: fail on wrong type 2025-02-10 15:23:50 +01:00
Christian Hesse
49d9fb1ffd global-functions: $RmDir: add debug output 2025-02-07 17:44:41 +01:00
Christian Hesse
7233dea5bb global-functions: $RmFile: add debug output 2025-02-07 17:44:41 +01:00
Christian Hesse
727495d9c4 global-functions: introduce $RmDir 2025-02-07 17:44:41 +01:00
Christian Hesse
4542c2b19e global-functions: introduce $RmFile 2025-02-07 17:44:41 +01:00
Christian Hesse
0fb5fd0323 global-functions: $MkDir: create directory directly...
... instead of file inside directory. This requires RouterOS 7.15, so
bumping requirement.
2025-02-07 17:44:32 +01:00
Christian Hesse
23d38927bc check-health: split off plugins...
... from 'check-health', so the script works on all devices to monitor
CPU and RAM. The supported plugins for sensors in hardware are installed
automatically.
2025-02-05 14:39:59 +01:00
Christian Hesse
414c83ef81 global-functions: $ScriptInstallUpdate: resolve more nested conditions
Just like the previous one.
2025-01-30 09:00:02 +01:00
Christian Hesse
8b19e74736 global-functions: $ScriptInstallUpdate: resolve nested conditions...
... and check one after another in a do-block. This uses `:error` as
poor man's continue. 🤪
2025-01-30 09:00:02 +01:00
Christian Hesse
b177e298d7 global-functions: $ScriptInstallUpdate: support checking for device-mode features 2025-01-30 09:00:02 +01:00
Christian Hesse
7be415d0ed global-functions: use short url rsc.eworm.de 2025-01-29 14:14:26 +01:00
Christian Hesse
9e3729c279 update copyright for 2025 2025-01-02 00:04:06 +01:00
Christian Hesse
b98b245714 global-functions: $WaitForFile: drop the first workaround
This reverts commit 8231c3e833.

Truned out this workaround was not sufficient, see the follow-up in
commit 191cc1b952 for details.

But possibly the second one does it on its own? Reverting this for
a test run.
2024-12-30 20:22:51 +01:00
Christian Hesse
191cc1b952 global-functions: $FetchHuge: another workaround for complete file
Turns out the workaround in $WaitForFile (commit
8231c3e833) is not sufficient. It helps
sometimes, but not always. Possibly depends on CPU speed and bandwidth
of internet connection... Who knows!? 🤪

But! Reading the file goes beyond the known file size. That's suspicious
and indicates this exact issue. So add a delay, and keep reading until
sizes are equal.
2024-12-30 20:09:46 +01:00
Christian Hesse
ef3ce7cc6c global-functions: $ParseKeyValueStore: support JSON as input
This used to require a key=value store, separated with commas. An
example for `netwatch-notify` is:

    /tool/netwatch/add comment="notify, name=example.com" host=93.184.215.14;

Now JSON is supported as well, so you could use:

    /tool/netwatch/add comment="{\"notify\":true,\"name\":\"example.com\"}" host=93.184.215.14;

Looks more clumsy here, but may be of help in more complex setups...
2024-12-25 23:04:50 +01:00
Christian Hesse
8212bd6c95 global-functions: $ParseKeyValueStore: properly return boolean values 2024-12-25 23:04:48 +01:00
Christian Hesse
ba39c29648 global-functions: $ParseKeyValueStore: split key and value...
... into separate variables.
2024-12-25 23:04:28 +01:00
Christian Hesse
8231c3e833 global-functions: $WaitForFile: delay until "complete"...
Well, turns out that waiting for existence of a file is not sufficient.
Chances are that a file is available just partly, so wait until the size
no longer changes... Let's hope that works as expected. 🤞
2024-12-17 11:20:09 +01:00
Christian Hesse
5b9031ccca global-functions: $SendNotification: use $ExitError to indicate unintentional error 2024-12-09 11:49:50 +01:00
Christian Hesse
8c5bd8f5e2 global-functions: $ScriptInstallUpdate: use $ExitError to indicate unintentional error 2024-12-09 11:49:50 +01:00
Christian Hesse
ff00c27f99 global-functions: $ExitError: give matching message for functions 2024-12-09 11:49:50 +01:00
Christian Hesse
ed6739b8bc global-functions: $ExitError: give script name in message 2024-12-09 11:49:50 +01:00
Christian Hesse
0d69f8952c global-functions: introduce $ExitError...
... as a simple macro to print error message on unintentional error.
2024-12-09 11:49:50 +01:00
Christian Hesse
48bcf8ee6e global-functions: $FetchHuge: passing boolean to function is still broken... 🤨 2024-12-09 11:49:50 +01:00
Christian Hesse
3506f71071 global-functions: $CertificateAvailable: fail without CommonName 2024-10-30 22:49:48 +01:00
Christian Hesse
c2c72818de global-functions: $CertificateDownload: add another check...
... that the certificate is really available.

Turns out that mkcert.org ships certificates where OU or whatever
matches - that's not what we want.
2024-09-26 15:24:05 +02:00
Christian Hesse
41b19b045a global-functions: $VersionToNum: support "zero"...
... to have a clean way to generate bitmasks.

    [admin@mikrotik] > :put [ $VersionToNum 0.255zero0 ]
    16711680
    [admin@mikrotik] > :put 0x00ff0000
    16711680

Once implemented everywhere the internal calculation could be
changed easily.
2024-09-13 10:22:06 +02:00
Christian Hesse
511184a4a7 global-functions: $EitherOr: revert...
... but leave a comment.
2024-07-22 21:14:03 +02:00
Christian Hesse
8ea7805541 global-functions: $EitherOr: pass boolean value
Note that literal "true" or "false" (even without quotes) is converted
to string. So you may have to enclose it in parentheses for a boolean
value:

    > :put [ :typeof [ $EitherOr true false ] ];
    str
    > :put [ :typeof [ $EitherOr (true) (false) ] ];
    bool
2024-07-22 18:28:56 +02:00
Christian Hesse
2fd0d27447 global-functions: $Unix2Dos: use :tocrlf 2024-07-16 13:50:22 +02:00
Christian Hesse
8f75d542f3 global-functions: $PrettyPrint: use :tocrlf 2024-07-16 13:50:22 +02:00
Christian Hesse
8074305b92 global-functions: $Dos2Unix: use :tolf 2024-07-16 13:50:22 +02:00
Christian Hesse
f2ca62aed0 global-functions: $ScriptInstallUpdate: support storing with CRLF
Adding this in `global-config-overlay` make the scripts being stored
with CRLF line breaks:

    :global ScriptUpdatesCRLF true;

Handle with care, I do not recommend it. Thus it's just a hidden
setting.
2024-07-16 13:50:22 +02:00
Christian Hesse
68f61ae622 global-functions: $ScriptInstallUpdate: allow CRLF on device 2024-07-16 13:50:22 +02:00
Christian Hesse
2d42fed621 global-functions: $ScriptInstallUpdate: forcibly convert to LF...
... to make sure we do not have unintended CRLF line breaks.
2024-07-16 13:50:22 +02:00
Christian Hesse
eab9b28cd2 global-functions: $MkDir: enable tmpfs if disabled 2024-07-04 15:31:43 +02:00