global-functions: $DeviceInfo: use $IfThenElse

This commit is contained in:
Christian Hesse 2020-07-16 21:06:13 +02:00
parent 910641b6fa
commit 4c61cd0b65

View file

@ -186,41 +186,31 @@
:global GlobalConfigVersion; :global GlobalConfigVersion;
:global Identity; :global Identity;
:global IfThenElse;
:local Resource [ / system resource get ]; :local Resource [ / system resource get ];
:local RouterBoard [ / system routerboard get ]; :local RouterBoard [ / system routerboard get ];
:local Update [ / system package update get ]; :local Update [ / system package update get ];
:local Info ( \ :return ( \
"Hostname: " . $Identity . "\n" . \ "Hostname: " . $Identity . \
"Board name: " . $Resource->"board-name" . "\n" . \ "\nBoard name: " . $Resource->"board-name" . \
"Architecture: " . $Resource->"architecture-name"); "\nArchitecture: " . $Resource->"architecture-name" . \
:if ($RouterBoard->"routerboard" = true) do={ [ $IfThenElse ($RouterBoard->"routerboard" = true) \
:local Revision ""; ("\nModel: " . $RouterBoard->"model" . \
:if ([ :len ($RouterBoard->"revision") ] > 0) do={ [ $IfThenElse ([ :len ($RouterBoard->"revision") ] > 0) \
:set Revision (" " . $RouterBoard->"revision"); (" " . $RouterBoard->"revision") ] . \
} "\nSerial number: " . $RouterBoard->"serial-number") ] . \
:set Info ($Info . "\n" . \ "\nRouterOS:" . \
"Model: " . $RouterBoard->"model" . $Revision . "\n" . \ "\n Channel: " . $Update->"channel" . \
"Serial number: " . $RouterBoard->"serial-number"); "\n Installed: " . $Update->"installed-version" . \
} [ $IfThenElse ([ :typeof ($Update->"latest-version") ] != "nothing" && \
:set Info ($Info . "\n" . \ $Update->"installed-version" != $Update->"latest-version") \
"RouterOS:\n" . \ ("\n Available: " . $Update->"latest-version") ] . \
" Channel: " . $Update->"channel" . "\n" . \ "\nRouterOS-Scripts Configuration Version:" . \
" Installed: " . $Update->"installed-version"); "\n Current: " . $GlobalConfigVersion . \
:if ([ :typeof ($Update->"latest-version") ] != "nothing" && \ [ $IfThenElse ($GlobalConfigVersion != $ExpectedConfigVersion) \
$Update->"installed-version" != $Update->"latest-version") do={ ("\n Expected: " . $ExpectedConfigVersion) ]);
:set Info ($Info . "\n" . \
" Available: " . $Update->"latest-version");
}
:set Info ($Info . "\n" . \
"RouterOS-Scripts Configuration Version:\n" . \
" Current: " . $GlobalConfigVersion);
:if ($GlobalConfigVersion != $ExpectedConfigVersion) do={
:set Info ($Info . "\n" . \
" Expected: " . $ExpectedConfigVersion);
}
:return $Info;
} }
# check if DNS is resolving # check if DNS is resolving