From e0afeaab139af9d3d591205e63a12ed8f7f79fe8 Mon Sep 17 00:00:00 2001 From: vados-dev <192440777+vados-dev@users.noreply.github.com> Date: Mon, 4 May 2026 19:10:04 +0300 Subject: [PATCH] Autocommit in repo: ros.vados.ru, generated by owner: root, in 19:10:03 04.05.2026. --- html/AM-GlobalFunc.rsc | 142 ++++++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 64 deletions(-) diff --git a/html/AM-GlobalFunc.rsc b/html/AM-GlobalFunc.rsc index 13542e180..0127c9485 100644 --- a/html/AM-GlobalFunc.rsc +++ b/html/AM-GlobalFunc.rsc @@ -17,9 +17,9 @@ :global GlobalFuncReady false; # Git commit id & info, expected configuration version -:global CommitId "main/583/f681a0d3"; +:global CommitId "main/584/d376e295"; :global CommitTAG "unknown"; -:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 18:55:02 04.05.2026."; +:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 19:10:03 04.05.2026."; # The variables are received right here. :global GlobalConfVersion 140; @@ -134,7 +134,7 @@ :global RequiredRouterOS; :global ExitError; :global ExitOnError; -:global FetchLargeFiles; + :global FetchHugeFiles; :global FetchUserAgentStr; :global FileExists; @@ -1412,67 +1412,67 @@ # "background-and-http-only", "background-and-no-redirects", "background-and-keep-broken-and-https-only", "background-and-keep-broken-and-http-only", # "background-and-keep-broken-and-no-redirects") # $5 - fetch method for /tool/fetch (optional, e.g. "get", "head", "post", "put", "patch", "delete") -:set FetchLargeFiles do={ - :local RunName [:tostr $1]; - :local fetchUrl [:tostr $2]; - :local fetchFile [:tostr $3]; - :local CheckCert [:tostr $4]; - :local fetchMode [:tostr $5]; - :local fetchMethod [:tostr $6]; - :local tmpName; - :global CleanName; - :global FetchUserAgentStr; - :global GetRandom20CharAlNum; - :global IfThenElse; - :global LogPrint; - :global MkDir; - :global RmDir; - :global RmFile; - :global WaitForFile; - - :set CheckCert [ $IfThenElse ($CheckCert = "false") "no" "yes-without-crl" ]; - - :set tmpName ($CleanName "tmp-" . [ $GetRandom20CharAlNum 6 ]); - :local DirName ("tmpfs/" . $tmpName); - :if ([ $MkDir $DirName ] = false) do={ - :log error ($RunName . " Failed creating directory: " . $DirName . "!"); - :return false; - } - - :local FileName ($DirName . "/" . [ $CleanName $fetchFile ] . "-" . [ $GetRandom20CharAlNum 5 ]); - :local Url ($fetchUrl . $fetchFile); - :onerror Err { - /tool/fetch check-certificate=$CheckCert $Url dst-path=$FileName \ - http-header-field=({ [ $FetchUserAgentStr $RunName ] }) as-value; - } do={ - :if ([ $WaitForFile $FileName 500ms ] = true) do={ - $RmFile $FileName; - } - :log error ($RunName . " Failed downloading from '" . $Url . "' - " . $Err); - $RmDir $DirName; - :return false; - } - - :if ([ $WaitForFile $FileName 5s ] = false) do={ - :log error ($RunName . " The file downloaded from '" . $Url . "' did not show up."); - :return false; - } - - :local FileSize [ /file/get $FileName size ]; - :local Return ""; - :local VarSize 0; - :while ($VarSize != $FileSize) do={ - :set Return ($Return . ([ /file/read offset=$VarSize chunk-size=32768 file=$FileName as-value ]->"data")); - :set FileSize [ /file/get $FileName size ]; - :set VarSize [ :len $Return ]; - :if ($VarSize > $FileSize) do={ - :delay 100ms; - } - } -# $RmFile $FileName; - $RmDir $DirName; - :return $Return; -} +#:set FetchLargeFiles do={ +# :local RunName [:tostr $1]; +# :local fetchUrl [:tostr $2]; +# :local fetchFile [:tostr $3]; +# :local CheckCert [:tostr $4]; +# :local fetchMode [:tostr $5]; +# :local fetchMethod [:tostr $6]; +# :local tmpName; +# :global CleanName; +# :global FetchUserAgentStr; +# :global GetRandom20CharAlNum; +# :global IfThenElse; +# :global LogPrint; +# :global MkDir; +# :global RmDir; +# :global RmFile; +# :global WaitForFile; +# +# :set CheckCert [ $IfThenElse ($CheckCert = "false") "no" "yes-without-crl" ]; +# +# :set tmpName ($CleanName "tmp-" . [ $GetRandom20CharAlNum 6 ]); +# :local DirName ("tmpfs/" . $tmpName); +# :if ([ $MkDir $DirName ] = false) do={ +# :log error ($RunName . " Failed creating directory: " . $DirName . "!"); +# :return false; +# } +# +# :local FileName ($DirName . "/" . [ $CleanName $fetchFile ] . "-" . [ $GetRandom20CharAlNum 5 ]); +# :local Url ($fetchUrl . $fetchFile); +# :onerror Err { +# /tool/fetch check-certificate=$CheckCert $Url dst-path=$FileName \ +# http-header-field=({ [ $FetchUserAgentStr $RunName ] }) as-value; +# } do={ +# :if ([ $WaitForFile $FileName 500ms ] = true) do={ +# $RmFile $FileName; +# } +# :log error ($RunName . " Failed downloading from '" . $Url . "' - " . $Err); +# $RmDir $DirName; +# :return false; +# } +# +# :if ([ $WaitForFile $FileName 5s ] = false) do={ +# :log error ($RunName . " The file downloaded from '" . $Url . "' did not show up."); +# :return false; +# } +# +# :local FileSize [ /file/get $FileName size ]; +# :local Return ""; +# :local VarSize 0; +# :while ($VarSize != $FileSize) do={ +# :set Return ($Return . ([ /file/read offset=$VarSize chunk-size=32768 file=$FileName as-value ]->"data")); +# :set FileSize [ /file/get $FileName size ]; +# :set VarSize [ :len $Return ]; +# :if ($VarSize > $FileSize) do={ +# :delay 100ms; +# } +# } +## $RmFile $FileName; +# $RmDir $DirName; +# :return $Return; +#} :set ScriptInstallUpdate do={ :onerror Err { :local Scripts [ :toarray $1 ]; @@ -1720,6 +1720,20 @@ :global ExitOnError; $ExitOnError $0 $Err; } } +# load modules +:foreach Script in=[ /system/script/find where name ~ "^(global-functions\\.d|mod)/." ] do={ + :local ScriptVal [ /system/script/get $Script ]; + :if ([ $ValidateSyntax ($ScriptVal->"source") ] = true) do={ + :onerror Err { + /system/script/run $Script; + } do={ + $LogPrint error $0 ("Module '" . $ScriptVal->"name" . "' failed to run: " . $Err); + } + } else={ + $LogPrint error $0 ("Module '" . $ScriptVal->"name" . "' failed syntax validation, skipping."); + } +} + # Add and fix global scheduler :put "Add or/and fix Global scheduler..."; :local OnEvent "/system/script { run AM-GlobalConfig; run AM-GlobalFunc; }"; -- 2.52.0