Compare commits

..

21 commits

Author SHA1 Message Date
Christian Hesse
125d96da9f update list of contributors 2025-06-02 23:53:27 +02:00
Christian Hesse
041e15dbaf check-routeros-update: remove a stale scheduler 2025-06-02 23:53:27 +02:00
Christian Hesse
c10838d58e packages-update: support deferred reboot with longer interval 2025-06-02 23:53:27 +02:00
Christian Hesse
346113dfb7 Merge branch 'file' into next 2025-06-02 23:53:27 +02:00
Christian Hesse
bc384f8802 capsman-download-packages: adopt new functionality from file menu 2025-06-02 23:53:27 +02:00
Christian Hesse
c7636cc9e5 capsman-download-packages: use $FileGet 2025-06-02 23:53:27 +02:00
Christian Hesse
91f641a59f telegram-chat: use $FileExists 2025-06-02 23:53:27 +02:00
Christian Hesse
abc02d8a94 mod/ssh-keys-import: use $FileExists 2025-06-02 23:53:27 +02:00
Christian Hesse
2014517439 mod/notification-email: use $RmFile 2025-06-02 23:53:27 +02:00
Christian Hesse
0b4a1d88e0 mod/notification-email: use $FileExists 2025-06-02 23:53:27 +02:00
Christian Hesse
a5248c7df1 backup-email: add a comment why files are not removed 2025-06-02 23:53:27 +02:00
Christian Hesse
7708666ffd backup-email: check for .conf file 2025-06-02 23:53:27 +02:00
Christian Hesse
6e050ed984 backup-email: use :retry and $FileExists 2025-06-02 22:54:46 +02:00
Christian Hesse
f8eff5b795 global-functions: $DownloadPackage: use $FileExists 2025-06-02 22:54:46 +02:00
Christian Hesse
beb0798bd5 global-functions: introduce $FileExists 2025-06-02 22:54:46 +02:00
Christian Hesse
27f374ff88 global-functions: $WaitForFile: use :retry for simplification, ...
... and to work around restrictions in new file handling
2025-06-02 22:54:30 +02:00
Christian Hesse
b418c69a88 global-functions: $WaitForFile: drop the workaround
This was fixed in RouterOS 7.18rc1, so should be ok to remove now.
2025-06-02 22:53:09 +02:00
Christian Hesse
396bfe511f global-functions: $RmFile: use $FileGet ...
... to work around restrictions in new file handling
2025-06-02 22:46:21 +02:00
Christian Hesse
460d105588 global-functions: $RmDir: use $FileGet ...
... to work around restrictions in new file handling
2025-06-02 22:46:16 +02:00
Christian Hesse
0d84476d31 global-functions: $MkDir: use $FileGet ...
... to work around restrictions in new file handling
2025-06-02 22:45:19 +02:00
Christian Hesse
d755b74345 global-functions: introduce $FileGet 2025-06-02 22:20:18 +02:00
7 changed files with 40 additions and 29 deletions

View file

@ -35,6 +35,7 @@ Add yourself to the list,
[donate with PayPal ↗️](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)!
* Abdul Mannan Abbasi
* Alex Maier
* Andrea Ruffini Perico
* Andrew Cox
* Christoph Boss (@Kampfwurst)

View file

@ -32,7 +32,6 @@
:global LogPrint;
:global MkDir;
:global RandomDelay;
:global RmDir;
:global ScriptFromTerminal;
:global ScriptLock;
:global SendEMail2;
@ -128,7 +127,8 @@
# wait for the mail to be sent
:do {
:retry {
:if ([ $FileExists ($FilePath . ".backup") "backup" ] = true || \
:if ([ $FileExists ($FilePath . ".conf") ".conf file" ] = true || \
[ $FileExists ($FilePath . ".backup") "backup" ] = true || \
[ $FileExists ($FilePath . ".rsc") "script" ] = true) do={
:error "Files are still available.";
}
@ -137,7 +137,7 @@
$LogPrint warning $ScriptName ("Files are still available, sending e-mail failed.");
:set PackagesUpdateBackupFailure true;
}
$RmDir $DirName;
# do not remove the files here, as the mail is still queued!
} do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
}

View file

@ -20,6 +20,7 @@
:global CleanFilePath;
:global DownloadPackage;
:global FileGet;
:global LogPrint;
:global MkDir;
:global RmFile;
@ -42,9 +43,7 @@
:error false;
}
:do {
/file/get $PackagePath;
} on-error={
:if ([ $FileGet $PackagePath ] = false) do={
:if ([ $MkDir $PackagePath ] = false) do={
$LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \
$PackagePath . ") failed!");

View file

@ -21,6 +21,7 @@
:global CleanFilePath;
:global DownloadPackage;
:global FileGet;
:global LogPrint;
:global MkDir;
:global RmFile;
@ -44,9 +45,7 @@
:error false;
}
:do {
/file/get $PackagePath;
} on-error={
:if ([ $FileGet $PackagePath ] = false) do={
:if ([ $MkDir $PackagePath ] = false) do={
$LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \
$PackagePath . ") failed!");

View file

@ -20,6 +20,7 @@
:global CleanFilePath;
:global DownloadPackage;
:global FileGet;
:global LogPrint;
:global MkDir;
:global RmFile;
@ -42,9 +43,7 @@
:error false;
}
:do {
/file/get $PackagePath;
} on-error={
:if ([ $FileGet $PackagePath ] = false) do={
:if ([ $MkDir $PackagePath ] = false) do={
$LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \
$PackagePath . ") failed!");

View file

@ -46,8 +46,8 @@ Configuration
The configuration goes to `global-config-overlay`, this is the only parameter:
* `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM
and 5 AM)
* `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM and
5 AM), use a numerical value in days suffixed with a `d` to defer further
By modifying the scheduler's `start-time` you can force the reboot at
different time.

View file

@ -39,6 +39,7 @@
:global FetchHuge;
:global FetchUserAgentStr;
:global FileExists;
:global FileGet;
:global FormatLine;
:global FormatMultiLines;
:global GetMacVendor;
@ -536,10 +537,10 @@
:local FileName [ :tostr $1 ];
:local Type [ :tostr $2 ];
:local FileVal;
:do {
:set FileVal [ /file/get $FileName ];
} on-error={
:global FileGet;
:local FileVal [ $FileGet $FileName ];
:if ($FileVal = false) do={
:return false;
}
@ -554,6 +555,20 @@
:return false;
}
# get file properties in array, or false on error
:set FileGet do={
:local FileName [ :tostr $1 ];
:local FileVal;
:do {
:set FileVal [ /file/get $FileName ];
} on-error={
:return false;
}
:return $FileVal;
}
# format a line for output
:set FormatLine do={
:local Key [ :tostr $1 ];
@ -905,6 +920,7 @@
:local Path [ :tostr $1 ];
:global CleanFilePath;
:global FileGet;
:global LogPrint;
:global RmDir;
:global WaitForFile;
@ -942,9 +958,8 @@
$LogPrint debug $0 ("Making directory: " . $Path);
:local PathVal;
:do { :set PathVal [ /file/get $Path ]; } on-error={ }
:if ($PathVal->"type"="directory") do={
:local PathVal [ $FileGet $Path ];
:if ($PathVal->"type" = "directory") do={
$LogPrint debug $0 ("... which already exists.");
:return true;
}
@ -1069,14 +1084,13 @@
:set RmDir do={
:local DirName [ :tostr $1 ];
:global FileGet;
:global LogPrint;
$LogPrint debug $0 ("Removing directory: ". $DirName);
:local DirVal;
:do {
:set DirVal [ /file/get $DirName ];
} on-error={
:local DirVal [ $FileGet $DirName ];
:if ($DirVal = false) do={
$LogPrint debug $0 ("... which does not exist.");
:return true;
}
@ -1099,14 +1113,13 @@
:set RmFile do={
:local FileName [ :tostr $1 ];
:global FileGet;
:global LogPrint;
$LogPrint debug $0 ("Removing file: ". $FileName);
:local FileVal;
:do {
:set FileVal [ /file/get $FileName ];
} on-error={
:local FileVal [ $FileGet $FileName ];
:if ($FileVal = false) do={
$LogPrint debug $0 ("... which does not exist.");
:return true;
}