From 59be230567fa43ad8c8f031a8aa4933dbd919315 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Sat, 5 Oct 2019 21:54:24 +0200 Subject: [PATCH] Prepared module for running as daemon --- icinga-module-windows.psm1 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/icinga-module-windows.psm1 b/icinga-module-windows.psm1 index be3c8e3..adfe97a 100644 --- a/icinga-module-windows.psm1 +++ b/icinga-module-windows.psm1 @@ -11,9 +11,28 @@ function Use-Icinga() { + param( + [switch]$LibOnly = $FALSE, + [switch]$Daemon = $FALSE + ); + # This function will allow us to load this entire module including possible # actions, making it available within our shell environment Import-IcingaLib '\' -Init; + + if ($LibOnly -eq $FALSE) { + $global:IcingaThreads = [hashtable]::Synchronized(@{}); + $global:IcingaThreadContent = [hashtable]::Synchronized(@{}); + $global:IcingaThreadPool = [hashtable]::Synchronized(@{}); + $global:IcingaDaemonData = [hashtable]::Synchronized( + @{ + 'IcingaThreads' = $global:IcingaThreads; + 'IcingaThreadContent' = $global:IcingaThreadContent; + 'IcingaThreadPool' = $global:IcingaThreadPool; + 'FrameworkRunningAsDaemon' = $Daemon; + } + ); + } } function Import-IcingaLib()