Compare commits

...

2 commits

Author SHA1 Message Date
Christian Hesse
bebf0206fe global-functions: set and fix global scheduler automatically...
... and also adjust README and INITIAL-COMMANDS.
2025-11-15 16:39:51 +01:00
Christian Hesse
6e57826bbe contrib/commitinfo: support updating the commit info 2025-11-13 19:34:10 +01:00
7 changed files with 21 additions and 7 deletions

View file

@ -45,9 +45,6 @@ Run the complete base installation:
};
:put "Loading configuration and 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={
:put "Renaming certificate by its common-name...";
:global CertificateNameByCN;

View file

@ -12,7 +12,7 @@ DATE ?= $(shell date --rfc-email)
VERSION ?= $(shell git symbolic-ref --short HEAD 2>/dev/null)/$(shell git rev-list --count HEAD 2>/dev/null)/$(shell git rev-parse --short=8 HEAD 2>/dev/null)
export DATE VERSION
.PHONY: all checksums docs rsc clean
.PHONY: all checksums commitinfo docs rsc clean
all: checksums docs rsc
@ -21,6 +21,9 @@ checksums: checksums.json
checksums.json: contrib/checksums.sh $(ALL_RSC)
contrib/checksums.sh > $@
commitinfo:
contrib/commitinfo.sh
docs: $(HTML)
%.html: %.md general/style.css contrib/html.sh contrib/html.sh.d/head.html

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)
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/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
> RouterOS on your device is too old. Check for updates!

6
contrib/commitinfo.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh
sed -i \
-e "/^:global CommitId/c :global CommitId \"${COMMITID:-unknown}\";" \
-e "/^:global CommitInfo/c :global CommitInfo \"${COMMITINFO:-unknown}\";" \
global-functions.rsc

View file

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