global-functions: add and fix global scheduler automatically...

... and also adjust README and INITIAL-COMMANDS.
This commit is contained in:
Christian Hesse 2025-11-13 19:48:02 +01:00
parent 097c158ec8
commit 02a7b15d0e
5 changed files with 12 additions and 6 deletions

View file

@ -45,9 +45,6 @@ Run the complete base installation:
}; };
:put "Loading configuration and functions..."; :put "Loading configuration and functions...";
/system/script { run global-config; run global-functions; }; /system/script { run global-config; run global-functions; };
:put "Scheduling to load configuration and functions...";
/system/scheduler/remove [ find where name="global-scripts" ];
/system/scheduler/add name="global-scripts" start-time=startup on-event="/system/script { run global-config; run global-functions; }";
:if ([ :len [ /certificate/find where fingerprint=$CertFingerprint ] ] > 0) do={ :if ([ :len [ /certificate/find where fingerprint=$CertFingerprint ] ] > 0) do={
:put "Renaming certificate by its common-name..."; :put "Renaming certificate by its common-name...";
:global CertificateNameByCN; :global CertificateNameByCN;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -129,12 +129,12 @@ Now let's download the main scripts and add them in configuration on the fly.
![screenshot: import scripts](README.d/04-import-scripts.avif) ![screenshot: import scripts](README.d/04-import-scripts.avif)
And finally load configuration and functions and add the scheduler. And finally run configuration and functions. This will also add the
scheduler for loading at system startup automatically.
/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; }";
![screenshot: run and schedule scripts](README.d/05-run-and-schedule-scripts.avif) ![screenshot: run scripts](README.d/05-run-scripts.avif)
> 💡️ **Hint**: You see complaints regarding syntax errors? Most likely the > 💡️ **Hint**: You see complaints regarding syntax errors? Most likely the
> RouterOS on your device is too old. Check for updates! > RouterOS on your device is too old. Check for updates!

View file

@ -1900,6 +1900,15 @@
} }
} }
# add (and fix) global scripts scheduler
:local OnEvent "/system/script { run global-config; run global-functions; }";
:if ([ :len [ /system/scheduler/find where name="global-scripts" ] ] = 0) do={
/system/scheduler/add name="global-scripts" start-time=startup;
}
:if ([ /system/scheduler/get "global-scripts" on-event ] != $OnEvent) do={
/system/scheduler/set "global-scripts" on-event=$OnEvent;
}
# Log success # Log success
:local Resource [ /system/resource/get ]; :local Resource [ /system/resource/get ];
$LogPrintOnce info $ScriptName ("Loaded on " . $Resource->"board-name" . \ $LogPrintOnce info $ScriptName ("Loaded on " . $Resource->"board-name" . \