global-functions: $IsTimeSync: calculate with uptime, drop scheduler

This commit is contained in:
Christian Hesse 2023-06-23 21:32:00 +02:00
parent ec7adcf78e
commit 640b8fd401

View file

@ -518,17 +518,18 @@
:return true;
}
:if ([ /system/resource/get uptime ] < 3m || $IsTimeSyncResetNtp = true) do={
:if ([ :typeof $IsTimeSyncResetNtp ] = "nothing") do={
:set IsTimeSyncResetNtp 0s;
}
:local Uptime [ /system/resource/get uptime ];
:if ($Uptime - $IsTimeSyncResetNtp < 3m) do={
:return false;
}
:set IsTimeSyncResetNtp true;
:set IsTimeSyncResetNtp $Uptime;
/system/ntp/client/set enabled=no;
:delay 20ms;
/system/ntp/client/set enabled=yes;
/system/scheduler/add name="clear-IsTimeSyncResetNtp" interval=1m \
on-event=("/system/scheduler/remove clear-IsTimeSyncResetNtp; " . \
":global IsTimeSyncResetNtp; :set IsTimeSyncResetNtp;");
:return false;
}