#!@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: