mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-01-21 00:19:32 +00:00
lease-script: early exit with :exit
This commit is contained in:
parent
5b667c2d0a
commit
f94ae82e3e
1 changed files with 4 additions and 8 deletions
|
|
@ -8,7 +8,6 @@
|
||||||
# run scripts on DHCP lease
|
# run scripts on DHCP lease
|
||||||
# https://rsc.eworm.de/doc/lease-script.md
|
# https://rsc.eworm.de/doc/lease-script.md
|
||||||
|
|
||||||
:local ExitOK false;
|
|
||||||
:onerror Err {
|
:onerror Err {
|
||||||
:global GlobalConfigReady; :global GlobalFunctionsReady;
|
:global GlobalConfigReady; :global GlobalFunctionsReady;
|
||||||
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
|
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
|
||||||
|
|
@ -26,22 +25,19 @@
|
||||||
[ :typeof $leaseServerName ] = "nothing" || \
|
[ :typeof $leaseServerName ] = "nothing" || \
|
||||||
[ :typeof $leaseBound ] = "nothing") do={
|
[ :typeof $leaseBound ] = "nothing") do={
|
||||||
$LogPrint error $ScriptName ("This script is supposed to run from ip dhcp-server.");
|
$LogPrint error $ScriptName ("This script is supposed to run from ip dhcp-server.");
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
:error false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$LogPrint debug $ScriptName ("DHCP Server " . $leaseServerName . " " . [ $IfThenElse ($leaseBound = 0) \
|
$LogPrint debug $ScriptName ("DHCP Server " . $leaseServerName . " " . [ $IfThenElse ($leaseBound = 0) \
|
||||||
"de" "" ] . "assigned lease " . $leaseActIP . " to " . $leaseActMAC);
|
"de" "" ] . "assigned lease " . $leaseActIP . " to " . $leaseActMAC);
|
||||||
|
|
||||||
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
|
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
:error false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :len [ /system/script/job/find where script=$ScriptName ] ] > 1) do={
|
:if ([ :len [ /system/script/job/find where script=$ScriptName ] ] > 1) do={
|
||||||
$LogPrint debug $ScriptName ("More invocations are waiting, exiting early.");
|
$LogPrint debug $ScriptName ("More invocations are waiting, exiting early.");
|
||||||
:set ExitOK true;
|
:exit;
|
||||||
:error true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:local RunOrder ({});
|
:local RunOrder ({});
|
||||||
|
|
@ -61,5 +57,5 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} do={
|
} do={
|
||||||
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
|
:global ExitError; $ExitError false [ :jobname ] $Err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue