Compare commits

...

3 commits

Author SHA1 Message Date
Christian Hesse
14b51d96b0 generate valid HTML, including head & style 2025-09-25 10:25:20 +02:00
Miquel Bonastre
2c715096b9 mod/ssh-keys-import: $SSHKeysImportFile: fix file exists condition...
... which broke in commit 80aed200fd.
2025-09-25 10:24:07 +02:00
Christian Hesse
2773fef9d8 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.
2025-09-25 10:24:07 +02:00
5 changed files with 31 additions and 10 deletions

View file

@ -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|' \

9
contrib/html.sh Executable file
View file

@ -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 '/<h[1234] /s| id="\(.*\)">| id="\L\1">|'
printf '</body></html>'

View file

@ -0,0 +1,15 @@
<!DOCTYPE html><html lang="en">
<head><title>RouterOS Scripts :: __TITLE__</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
body { font-family: sans-serif; }
h2 { border-bottom: 1px solid #ccc; color: #000; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
blockquote { border-left: 4px solid #ccc; padding: 0 10px; color: #777; }
code { margin: 0 2px; padding: 2px 5px; border: 1px solid #ccc; background-color: #f8f8f8; border-radius: 3px; }
pre { background-color: #f8f8f8; border: 1px solid #ccc; overflow: auto; padding: 6px 10px; border-radius: 3px; }
pre code { margin: 0; padding: 0; border: 0; }
</style>
<link rel="icon" href="/logo.png" type="image/png">
</head><body>

View file

@ -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 {

View file

@ -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;
}