aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-02-24 10:48:04 +0100
committerGravatar Christian Hesse <mail@eworm.de>2020-02-24 10:48:04 +0100
commit7d2239f24e01497e94c181b247f119592d253eb7 (patch)
tree948717fc58db36ea196f27ec4bf597a49e2b9e27
parent23fe30c4e1134d67650ee0cce2acc350ed154644 (diff)
global-functions: introduce $MailServerIsUp
-rw-r--r--global-functions22
1 files changed, 22 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index d4b8801..7d242e6 100644
--- a/global-functions
+++ b/global-functions
@@ -34,6 +34,7 @@
:global RandomDelay;
:global DeviceInfo;
:global ScriptInstallUpdate;
+:global MailServerIsUp;
# url encoding
:set UrlEncode do={
@@ -436,3 +437,24 @@
}
/ system script run script-updates;
}
+
+# check if mail server is up
+:set MailServerIsUp do={
+ :local MailServer [ / tool e-mail get address ];
+ :local MailHost $MailServer;
+
+ :if ([ / tool netwatch print count-only where comment=$MailServer ] = 0) do={
+ :log warn ("Adding netwatch entry for mail server.");
+ :local MailHost $MailServer;
+ :if ([ :typeof [ :toip $MailHost ] ] != "ip" ) do={
+ :set MailHost [ :resolve $MailServer ];
+ }
+ / tool netwatch add comment=$MailServer host=[ :resolve $MailServer ];
+ }
+
+ :if ([ / tool netwatch get [ find where comment=$MailServer ] status ] = "up") do={
+ :return true;
+ }
+
+ :return false;
+}