From 0857f1201f5d45d2c3b7136f16eff2de2407fa15 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Thu, 2 Nov 2023 13:16:57 +0100
Subject: [PATCH] director cli: fix json genration for mult.ports

---
 director-cli.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/director-cli.sh b/director-cli.sh
index bc10d3d..f5c2e4e 100755
--- a/director-cli.sh
+++ b/director-cli.sh
@@ -21,10 +21,11 @@
 # 2023-02-17  v0.6  ah  remove invalid line in cleanup
 # 2023-02-17  v0.7  ah  check inc_getconfig.sh exists and hostname -f has a value
 # 2023-10-25  v0.8  ah  generate json with "jo"; optimze http requests on services; parallel service function call
+# 2023-11-02  v0.9  ah  fix json genration for multiple ports
 # ======================================================================
 
 
-_version="0.8"
+_version="0.9"
 
 which curl >/dev/null || exit 1
 which jo   >/dev/null || exit 1
@@ -118,14 +119,14 @@ hostDefaultgroups="groups[]=iml groups[]=iml-server"
     # check if host is in a private network:
     if echo "$MY_IP" | grep -E "${regexPrivateNetworks}" >/dev/null
     then
-      JSONPARAMS+='imports[]="${hostImportPrivate}" '
+      JSONPARAMS+='imports[]="'${hostImportPrivate}'" '
     else
-      JSONPARAMS+='imports[]="${hostImportReachable}" '
+      JSONPARAMS+='imports[]="'${hostImportReachable}'" '
     fi
 
     # port checks initiated by icinga server to monitor client
     if [ -n "${host_vars_tcpport}" -a "${host_vars_tcpport}" != "[]" ]; then
-      JSONPARAMS+='vars.tcp_port=${host_vars_tcpport} '
+      JSONPARAMS+='vars.tcp_port="'${host_vars_tcpport}'" '
     fi
 
     # ----- host groups
@@ -324,6 +325,7 @@ hostDefaultgroups="groups[]=iml groups[]=iml-server"
 
     # --- get json data of object
     if [ $_bSendData = true ]; then
+      echo "$_jsonparams"
       _jsondata=$( eval jo -p -d. $_jsonparams )
     fi
 
-- 
GitLab