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>
This commit is contained in:
Alexey Abramov 2021-09-29 08:57:42 +02:00 committed by Jonathan Brielmaier
parent 5dfa6bfb48
commit 3246eac4fe
No known key found for this signature in database
GPG key ID: ECFC83988B4E4B9F

View file

@ -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)