aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-06-17 00:23:00 +0200
committerGravatar Christian Hesse <mail@eworm.de>2022-06-20 11:29:49 +0200
commitb1ad89b1b5d387bdde9527d80f62fcb9c5c4d4e1 (patch)
treee567ebed1899ca1cc059fb652e7329951da55111
parent9aa82316c8926773724e2dde24d58594c96bb832 (diff)
global-functions: rename internal function: $TimeIsSync -> $IsTimeSync
-rw-r--r--global-functions66
1 files changed, 33 insertions, 33 deletions
diff --git a/global-functions b/global-functions
index 79aedb7..9745591 100644
--- a/global-functions
+++ b/global-functions
@@ -34,6 +34,7 @@
:global IfThenElse;
:global IsDefaultRouteReachable;
:global IsDNSResolving;
+:global IsTimeSync;
:global LogPrintExit2;
:global MkDir;
:global NotificationFunctions;
@@ -51,7 +52,6 @@
:global SendNotification2;
:global SymbolByUnicodeName;
:global SymbolForNotification;
-:global TimeIsSync;
:global UrlEncode;
:global ValidateSyntax;
:global VersionToNum;
@@ -323,13 +323,13 @@
:global EmailQueue;
:global EitherOr;
+ :global IsTimeSync;
:global LogPrintExit2;
- :global TimeIsSync;
:local AllDone true;
:local QueueLen [ :len $EmailQueue ];
- :if ([ $TimeIsSync ] = false) do={
+ :if ([ $IsTimeSync ] = false) do={
$LogPrintExit2 debug $0 ("Time is not synced, not flushing.") false;
:return false;
}
@@ -462,6 +462,34 @@
:return true;
}
+# check if system time is sync
+:set IsTimeSync do={
+ :global LogPrintExit2;
+
+ :if ([ /system/ntp/client/get enabled ] = true) do={
+ :do {
+ :if ([ /system/ntp/client/get status ] = "synchronized") do={
+ :return true;
+ }
+ } on-error={
+ :if ([ :typeof [ /system/ntp/client/get last-adjustment ] ] = "time") do={
+ :return true;
+ }
+ }
+ :return false;
+ }
+
+ :if ([ /ip/cloud/get ddns-enabled ] = true && [ /ip/cloud/get update-time ] = true) do={
+ :if ([ :typeof [ /ip/cloud/get public-address ] ] = "ip") do={
+ :return true;
+ }
+ :return false;
+ }
+
+ $LogPrintExit2 debug $0 ("No time source configured! Returning gracefully...") false;
+ :return true;
+}
+
# log and print with same text, optionally exit
:set LogPrintExit2 do={
:local Severity [ :tostr $1 ];
@@ -1110,34 +1138,6 @@
:return ($Return . " ");
}
-# check if system time is sync
-:set TimeIsSync do={
- :global LogPrintExit2;
-
- :if ([ /system/ntp/client/get enabled ] = true) do={
- :do {
- :if ([ /system/ntp/client/get status ] = "synchronized") do={
- :return true;
- }
- } on-error={
- :if ([ :typeof [ /system/ntp/client/get last-adjustment ] ] = "time") do={
- :return true;
- }
- }
- :return false;
- }
-
- :if ([ /ip/cloud/get ddns-enabled ] = true && [ /ip/cloud/get update-time ] = true) do={
- :if ([ :typeof [ /ip/cloud/get public-address ] ] = "ip") do={
- :return true;
- }
- :return false;
- }
-
- $LogPrintExit2 debug $0 ("No time source configured! Returning gracefully...") false;
- :return true;
-}
-
# url encoding
:set UrlEncode do={
:local Input [ :tostr $1 ];
@@ -1256,9 +1256,9 @@
# wait for time to become synced
:set WaitTimeSync do={
- :global TimeIsSync;
+ :global IsTimeSync;
- :while ([ $TimeIsSync ] = false) do={
+ :while ([ $IsTimeSync ] = false) do={
:delay 1s;
}
}