From 562390f364b61bcaedbc635dc524f3e90efe14a6 Mon Sep 17 00:00:00 2001
From: Jonas Wielicki <j.wielicki@sotecware.net>
Date: Thu, 26 Apr 2018 20:30:35 +0200
Subject: Proper switch for debug mode

---
 echoz.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

(limited to 'echoz.sh')

diff --git a/echoz.sh b/echoz.sh
index b6c14f2..e5b8321 100755
--- a/echoz.sh
+++ b/echoz.sh
@@ -12,6 +12,15 @@ port="$(echo "$srv" | cut -d' ' -f3)"
 authstr="$(echo -ne "\0$username\0$password" | base64)"
 rm -f "$pipename"
 mkfifo "$pipename"
+DEBUG_PATH=${DEBUG_PATH:-}
+if [[ "x$DEBUG_PATH" != "x" ]]; then
+  debug_recv="${DEBUG_PATH}recv.xml"
+  debug_sent="${DEBUG_PATH}sent.xml"
+  rm -f "$debug_sent" "$debug_recv"
+else
+  debug_recv=/dev/null
+  debug_sent=/dev/null
+fi
 stdbuf -i0 -o0 \
   openssl s_client \
     -starttls xmpp \
@@ -21,7 +30,9 @@ stdbuf -i0 -o0 \
     < "$pipename" \
   | (echo -ne "$jid $authstr\n"; \
      stdbuf -o0 tr '>\n' '\n\001') \
+  | stdbuf -o0 tee "$debug_recv" \
   | stdbuf -o0 "$thisdir/echoz.sed" \
+  | stdbuf -o0 tee "$debug_sent" \
   | stdbuf -o0 tr -d '\n' \
   | stdbuf -o0 tr '\001' '\n' \
     > "$pipename"
-- 
cgit v1.2.3