mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
services: rsync: Use make-inetd-constructor.
* gnu/services/rsync.scm (rsync-shepherd-service): Use make-inetd-constructor if available in start slot. * gnu/tests/rsync.scm (run-rsync-test): Delete "PID file" test. Reviewed-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
deda3cc905
commit
03e601da49
2 changed files with 36 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com>
|
;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com>
|
||||||
;;; Copyright © 2021, 2023 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2021, 2023 Ludovic Courtès <ludo@gnu.org>
|
||||||
|
;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -221,23 +222,50 @@ (define modules
|
||||||
|
|
||||||
(define (rsync-shepherd-service config)
|
(define (rsync-shepherd-service config)
|
||||||
"Return a <shepherd-service> for rsync with CONFIG."
|
"Return a <shepherd-service> for rsync with CONFIG."
|
||||||
|
|
||||||
|
;; XXX: Predicates copied from (gnu services ssh).
|
||||||
|
(define inetd-style?
|
||||||
|
#~(and (defined? 'make-inetd-constructor)
|
||||||
|
(not (string=? (@ (shepherd config) Version) "0.9.0"))))
|
||||||
|
|
||||||
|
(define ipv6-support?
|
||||||
|
#~(catch 'system-error
|
||||||
|
(lambda ()
|
||||||
|
(let ((sock (socket AF_INET6 SOCK_STREAM 0)))
|
||||||
|
(close-port sock)
|
||||||
|
#t))
|
||||||
|
(const #f)))
|
||||||
|
|
||||||
(let* ((rsync (rsync-configuration-package config))
|
(let* ((rsync (rsync-configuration-package config))
|
||||||
(pid-file (rsync-configuration-pid-file config))
|
(pid-file (rsync-configuration-pid-file config))
|
||||||
(port-number (rsync-configuration-port-number config))
|
(port-number (rsync-configuration-port-number config))
|
||||||
(user (rsync-configuration-user config))
|
(user (rsync-configuration-user config))
|
||||||
(group (rsync-configuration-group config))
|
(group (rsync-configuration-group config))
|
||||||
(config-file (rsync-config-file config)))
|
(config-file (rsync-config-file config))
|
||||||
|
(rsync-command #~(list (string-append #$rsync "/bin/rsync")
|
||||||
|
"--config" #$config-file "--daemon")))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(provision '(rsync))
|
(provision '(rsync))
|
||||||
(documentation "Run rsync daemon.")
|
(documentation "Run rsync daemon.")
|
||||||
(actions (list (shepherd-configuration-action config-file)))
|
(actions (list (shepherd-configuration-action config-file)))
|
||||||
(start #~(make-forkexec-constructor
|
(start #~(if #$inetd-style?
|
||||||
(list (string-append #$rsync "/bin/rsync")
|
(make-inetd-constructor
|
||||||
"--config" #$config-file
|
#$rsync-command
|
||||||
"--daemon")
|
(cons (endpoint
|
||||||
#:pid-file #$pid-file
|
(make-socket-address AF_INET INADDR_ANY
|
||||||
#:user #$user
|
#$port-number))
|
||||||
#:group #$group))
|
(if #$ipv6-support?
|
||||||
|
(list
|
||||||
|
(endpoint
|
||||||
|
(make-socket-address AF_INET6 IN6ADDR_ANY
|
||||||
|
#$port-number)))
|
||||||
|
'()))
|
||||||
|
#:user #$user
|
||||||
|
#:group #$group)
|
||||||
|
(make-forkexec-constructor #$rsync-command
|
||||||
|
#:pid-file #$pid-file
|
||||||
|
#:user #$user
|
||||||
|
#:group #$group)))
|
||||||
(stop #~(make-kill-destructor))))))
|
(stop #~(make-kill-destructor))))))
|
||||||
|
|
||||||
(define rsync-service-type
|
(define rsync-service-type
|
||||||
|
|
|
@ -70,12 +70,6 @@ (define marionette
|
||||||
(start-service 'rsync))
|
(start-service 'rsync))
|
||||||
marionette))
|
marionette))
|
||||||
|
|
||||||
;; Make sure the PID file is created.
|
|
||||||
(test-assert "PID file"
|
|
||||||
(marionette-eval
|
|
||||||
'(file-exists? "/var/run/rsyncd/rsyncd.pid")
|
|
||||||
marionette))
|
|
||||||
|
|
||||||
(test-assert "Test file copied to share"
|
(test-assert "Test file copied to share"
|
||||||
(marionette-eval
|
(marionette-eval
|
||||||
'(begin
|
'(begin
|
||||||
|
|
Loading…
Reference in a new issue