From 6b0c9ab17d2e7e3693cebf281e5300d1e4de3446 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 15 Sep 2025 13:10:12 +0200 Subject: [PATCH 1/4] packages-update: exit early if scheduler exists --- packages-update.rsc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages-update.rsc b/packages-update.rsc index d3140f29..cfe5222e 100644 --- a/packages-update.rsc +++ b/packages-update.rsc @@ -41,6 +41,11 @@ /system/reboot; } + :if ([ /system/scheduler/find where name="_RebootForUpdate" ] > 0) do={ + $LogPrint warning $ScriptName ("Scheduler for reboot already exists."); + :return false; + } + :local Interval [ $IfThenElse ([ :totime $PackagesUpdateDeferReboot ] >= 1d) \ $PackagesUpdateDeferReboot 1d ]; :local StartTime [ :tostr [ :totime (10800 + [ $GetRandomNumber 7200 ]) ] ]; From 2773fef9d80fe8f7e2abdec767da5c5dcb64ddaf Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 19 Sep 2025 17:20:37 +0200 Subject: [PATCH 2/4] global-functions: $WaitForFile: try less expensive operation Checking a specific file is less expensive operation than finding one, especially when on hardware with huge storage and lots of files (like RDS). We have to keep the find command in the latter loop, though. --- global-functions.rsc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 10d1b412..98bc306c 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1787,14 +1787,11 @@ :local Delay ([ $MAX [ $EitherOr $WaitTime 2s ] 100ms ] / 9); :do { - :retry { - :if ([ :len [ /file/find where name=$FileName ] ] = 0) do={ - :error false; - } + :retry { + /file/get $FileName; + :return true; } delay=$Delay max=10; - } on-error={ - :return false; - } + } on-error={ } :while ([ :len [ /file/find where name=$FileName ] ] > 0) do={ :do { From 2c715096b994811fbc914f68412db91f5bd62618 Mon Sep 17 00:00:00 2001 From: Miquel Bonastre Date: Wed, 24 Sep 2025 15:17:36 +0200 Subject: [PATCH 3/4] mod/ssh-keys-import: $SSHKeysImportFile: fix file exists condition... ... which broke in commit 80aed200fd7400e4a4958ba314912488780be635. --- mod/ssh-keys-import.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc index 7bdc95da..dd32fd6b 100644 --- a/mod/ssh-keys-import.rsc +++ b/mod/ssh-keys-import.rsc @@ -85,7 +85,7 @@ :return false; } - :if ([ $FileExists $FileName ] = true) do={ + :if ([ $FileExists $FileName ] = false) do={ $LogPrint warning $0 ("File '" . $FileName . "' does not exist."); :return false; } From 14b51d96b0b9fd80e0364407f377c26e8e0222ec Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 16 Sep 2025 12:01:32 +0200 Subject: [PATCH 4/4] generate valid HTML, including head & style --- Makefile | 4 ++-- contrib/html.sh | 9 +++++++++ contrib/html.sh.d/head.html | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 contrib/html.sh create mode 100644 contrib/html.sh.d/head.html diff --git a/Makefile b/Makefile index 89517410..0265a51a 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,8 @@ HTML = $(MARKDOWN:.md=.html) all: $(CAPSMAN) $(LOCAL) $(WIFI) $(HTML) checksums.json -%.html: %.md Makefile - markdown $< | sed 's/href="\([-_\./[:alnum:]]*\)\.md"/href="\1.html"/g' > $@ +%.html: %.md contrib/html.sh contrib/html.sh.d/head.html + contrib/html.sh $< > $@ %.capsman.rsc: %.template.rsc Makefile sed -e '/\/interface\/wifi\//d' -e '/\/interface\/wireless\//d' -e 's|%TEMPL%|.capsman|' \ diff --git a/contrib/html.sh b/contrib/html.sh new file mode 100755 index 00000000..bbd8ba86 --- /dev/null +++ b/contrib/html.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +sed "s|__TITLE__|$(head -n1 "${1}")|" < "${0}.d/head.html" +markdown -f toc,idanchor "${1}" | sed \ + -e 's/href="\([-_\./[:alnum:]]*\)\.md"/href="\1.html"/g' \ + -e '/| id="\L\1">|' +printf '' diff --git a/contrib/html.sh.d/head.html b/contrib/html.sh.d/head.html new file mode 100644 index 00000000..1b1dd03a --- /dev/null +++ b/contrib/html.sh.d/head.html @@ -0,0 +1,15 @@ + +RouterOS Scripts :: __TITLE__ + + + +