From 3246eac4fe6d7cab88ea21d9de902caf4aa6e522 Mon Sep 17 00:00:00 2001
From: Alexey Abramov <Alexey_Abramov1@epam.com>
Date: Wed, 29 Sep 2021 08:57:42 +0200
Subject: [PATCH] services: zerotier-one: Display output of actions to the
 user.

Fixes https://gitlab.com/nonguix/nonguix/-/issues/117.

* nongnu/services/vpn.scm (%zerotier-action-join): call command via
open-input-pipe and print exit code.
(%zerotier-action-leave): dito.

Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
---
 nongnu/services/vpn.scm | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/nongnu/services/vpn.scm b/nongnu/services/vpn.scm
index 0bd26c7..b76cf03 100644
--- a/nongnu/services/vpn.scm
+++ b/nongnu/services/vpn.scm
@@ -29,16 +29,26 @@
    (name 'join)
    (documentation "Join a network")
    (procedure #~(lambda (running network)
-                  (let ((zerotier-cli (string-append #$zerotier "/sbin/zerotier-cli")))
-                    (invoke zerotier-cli "join" network))))))
+                  (let* ((zerotier-cli (string-append #$zerotier "/sbin/zerotier-cli"))
+                         (cmd (string-join (list zerotier-cli "join" network)))
+                         (port (open-input-pipe cmd))
+                         (str (get-string-all port)))
+                    (display str)
+                    (status:exit-val (close-pipe port)))))))
 
 (define %zerotier-action-leave
   (shepherd-action
    (name 'leave)
    (documentation "Leave a network")
    (procedure #~(lambda (running network)
-                  (let ((zerotier-cli (string-append #$zerotier "/sbin/zerotier-cli")))
-                    (invoke zerotier-cli "leave" network))))))
+                  (let* ((zerotier-cli (string-append #$zerotier "/sbin/zerotier-cli"))
+                         (cmd (string-join (list zerotier-cli "leave" network)))
+                         (port (open-input-pipe cmd))
+                         (str (get-string-all port)))
+                    (display str)
+                    (status:exit-val (close-pipe port)))))))
+
+
 
 (define zerotier-one-shepherd-service
   (lambda (config)