mirror of
https://github.com/beeyev/Mikrotik-RouterOS-automatic-backup-and-update.git
synced 2025-07-15 08:24:37 +02:00
Update v3.rsc to enforce patch update installation and improve error logging for invalid update channels
This commit is contained in:
parent
7f42df08e5
commit
d35919a966
1 changed files with 5 additions and 22 deletions
27
v3.rsc
27
v3.rsc
|
@ -48,7 +48,7 @@
|
||||||
## Means that new update will be installed only if MAJOR and MINOR version numbers remained the same as currently installed RouterOS.
|
## Means that new update will be installed only if MAJOR and MINOR version numbers remained the same as currently installed RouterOS.
|
||||||
## Example: v6.43.6 => major.minor.PATCH
|
## Example: v6.43.6 => major.minor.PATCH
|
||||||
## Script will send information if new version is greater than just patch.
|
## Script will send information if new version is greater than just patch.
|
||||||
:local installOnlyPatchUpdates false
|
:local installOnlyPatchUpdates true
|
||||||
|
|
||||||
## If true, device public IP address information will be included into the email message
|
## If true, device public IP address information will be included into the email message
|
||||||
:local detectPublicIpAddress true
|
:local detectPublicIpAddress true
|
||||||
|
@ -116,31 +116,14 @@ if ($updateChannel != "stable" and $updateChannel != "long-term" and $updateChan
|
||||||
# Check if the script is set to install only patch updates and if the update channel is valid
|
# Check if the script is set to install only patch updates and if the update channel is valid
|
||||||
if ($scriptMode = "osupdate" and $installOnlyPatchUpdates=true) do={
|
if ($scriptMode = "osupdate" and $installOnlyPatchUpdates=true) do={
|
||||||
if ($updateChannel != "stable" and $updateChannel != "long-term") do={
|
if ($updateChannel != "stable" and $updateChannel != "long-term") do={
|
||||||
:log error ("$SMP Script parameter `\$installOnlyPatchUpdates` is set to true, but the update channel is not valid: `$updateChannel`. Script stopped.")
|
:log error ("$SMP Script is set to install only patch updates, but the update channel is not valid: `$updateChannel`. Only `stable` and `long-term` channels supported. Script stopped.")
|
||||||
:error $exitErrorMessage
|
:error $exitErrorMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
:local isValidVersionString do={
|
:local susInstalledOsChannel [/system resource get version]
|
||||||
:local version $1
|
|
||||||
:local allowedChars "0123456789."
|
|
||||||
:local i 0
|
|
||||||
:local c ""
|
|
||||||
|
|
||||||
# Check each character
|
if ([:len [:find $susInstalledOsChannel "stable"]] = 0 and [:len [:find $susInstalledOsChannel "long-term"]] = 0) do={
|
||||||
:for i from=0 to=([:len $version] - 1) do={
|
:log error ("$SMP Script is set to install only patch updates, but the installed RouterOS version is not from `stable` or `long-term` channel: `$susInstalledOsChannel`. Script stopped.")
|
||||||
:set c [:pick $version $i]
|
|
||||||
:if ([:len [:find $allowedChars $c]] = 0) do={
|
|
||||||
:return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
:return true
|
|
||||||
}
|
|
||||||
|
|
||||||
:local susInstalledOs [/system package update get installed-version]
|
|
||||||
|
|
||||||
:if ([$isValidVersionString $susInstalledOs] = true) do={
|
|
||||||
:log error ("$SMP Current RouterOS is testing or development version: `$susInstalledOs`, patch updates supported only for stable and long-term versions. Script stopped.")
|
|
||||||
:error $exitErrorMessage
|
:error $exitErrorMessage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue