blob: f6f3a9a6fb6614223a0e3a17a888c91988227138 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#!@GUILE@ \
--no-auto-compile -e main -s
!#
;;; Whispers --- Stealth VPN and ssh tunneler
;;; Copyright © 2024 Runciter <runciter@whispers-vpn.org>
;;;
;;; This file is part of Whispers.
;;;
;;; Whispers is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; Whispers is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with Whispers. If not, see <http://www.gnu.org/licenses/>.
(use-modules (config))
(use-modules (whispers))
(define herd-path "/run/current-system/profile/bin/herd")
(define config
(configuration
(name 'whispers)
(version "0.1")
(keywords
(list
(switch
(name 'lieutenant)
(character #\l)
(default "/")
(example "LIEUTENANT-PATH ACTION [SERVICE [ARG...]]")
(test (lambda (lieutenant-path)
(equal? "/" (substring lieutenant-path 0 1))))
(synopsis "Absolute lieutenant path, and arguments passed to herd."))
(switch
(name 'vers-herd)
(test boolean?)
(default #f)
(character #f)
(synopsis "Display the herd version."))
(switch
(name 'help-herd)
(test boolean?)
(character #f)
(default #f)
(synopsis "Display the help message of herd."))
(switch
(name 'usage-herd)
(test boolean?)
(character #f)
(default #f)
(synopsis "Display the short usage message of herd."))))
(synopsis "Send commands to shepherd lieutenants of the whispers tree.")
(description "The whispers command is a simple convenience wrapper
around the herd program. Instead of specifying a file path
to the listening socket of a running shepherd in the whispers tree, the
user simply provides its absolute whispers tree path as an
argument to the --lieutenant option of this command.
LIEUTENANT-PATH: absolute path to a shepherd lieutenant in the whispers
tree. Must start with a slash character.
ACTION: the shepherd service action to perform.
SERVICE: the shepherd service of which the ACTION is to be performed.
ARG...: arguments passed to the procedure of the shepherd action.
If the --lieutenant switch and its LIEUTENANT-PATH argument are omitted,
an action is performed on a service of the shepherd at the root of the
whispers tree, which is itself a child process of the root shepher PID 1
handled as one of its services. As such, using
'whispers -l / ACTION [SERVICE [ARG...]]'
or
'whispers ACTION [SERVICE [ARG...]]'
have exactly the same effect.")))
(define (main cmd-line)
(let ((options (getopt-config-auto cmd-line config)))
(cond ((option-ref options 'help-herd)
(system* herd-path
"--help"))
((option-ref options 'vers-herd)
(system* herd-path
"--version"))
((option-ref options 'usage-herd)
(system* herd-path
"--usage"))
(else (whispers #:lieutenant
(option-ref options 'lieutenant)
#:act
(cond ((or (equal? "-l"
(cadr (command-line)))
(equal? "--lieutenant"
(cadr (command-line))))
(cdddr (command-line)))
(else (cdr (command-line)))))))))
;;; Local Variables:
;;; mode: scheme
;;; End:
|