unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 9cf2bc89ad589f60de47c4627dcc555ef463d1d1 5820 bytes (raw)
name: gnu/services/rsync.scm 	 # note: path name is non-authoritative(*)

  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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
 
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix 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.
;;;
;;; GNU Guix 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 GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu services rsync)
  #:use-module (gnu services)
  #:use-module (gnu services base)
  #:use-module (gnu services shepherd)
  #:use-module (gnu system shadow)
  #:use-module (gnu packages rsync)
  #:use-module (gnu packages admin)
  #:use-module (guix records)
  #:use-module (guix gexp)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:use-module (ice-9 match)
  #:export (rsync-configuration
            rsync-configuration?
            rsync-service-type))

;;;
;;; Rsync.
;;;

(define-record-type* <rsync-configuration>
  rsync-configuration make-rsync-configuration
  rsync-configuration?
  ;; <package>
  (package rsync-configuration-package
           (default rsync))
  ;; integer
  (port-number rsync-configuration-port-number
               (default 873))
  ;; string
  (pid-file rsync-configuration-pid-file
            (default "/var/run/rsyncd.pid"))
  ;; string
  (lock-file rsync-configuration-lock-file
             (default "/var/run/rsyncd.lock"))
  ;; string
  (log-file rsync-configuration-log-file
            (default "/var/log/rsyncd.log"))
  ;; Boolean
  (use-chroot? rsync-configuration-use-chroot?
               (default #f))
  ;; string
  (share-path rsync-configuration-share-path
              (default "/srv/rsync"))
  ;; string
  (share-comment rsync-configuration-share-comment
                 (default "Rsync share"))
  ;; Boolean
  (read-only? rsync-configuration-read-only?
              (default #f))
  ;; integer
  (timeout rsync-configuration-timeout
           (default 300)))

(define %rsync-accounts
  ;; User account and group for rsync.
  (list (user-group (name "rsyncd") (system? #t))
        (user-account
         (name "rsyncd")
         (system? #t)
         (group "rsyncd")
         (comment "rsyncd privilege separation user")
         (home-directory "/var/run/rsyncd")
         (shell #~(string-append #$shadow "/sbin/nologin")))))

(define (rsync-activation config)
  "Return the activation GEXP for CONFIG."
  #~(begin
      (use-modules (guix build utils))
      (let ((share-directory #$(rsync-configuration-share-path config))
            (user (getpw "rsyncd")))
        (and=> share-directory mkdir-p)
        (chown share-directory
               (passwd:uid user)
               (group:gid user)))))

(define (rsync-config-file config)
  "Return the rsync configuration file corresponding to CONFIG."
  (computed-file
   "rsync.conf"
   #~(begin
       (call-with-output-file #$output
         (lambda (port)
           (display "# Generated by 'rsync-service'.\n" port)
           (format port "pid file = ~a\n"
                   #$(rsync-configuration-pid-file config))
           (format port "lock file = ~a\n"
                   #$(rsync-configuration-lock-file config))
           (format port "log file = ~a\n"
                   #$(rsync-configuration-log-file config))
           (format port "port = ~a\n"
                   #$(number->string
                      (rsync-configuration-port-number config)))
           (format port "use chroot = ~a\n"
                   #$(if (rsync-configuration-use-chroot? config)
                         "true" "false"))
           (display "gid = rsyncd\n" port)
           (display "[files]\n" port)
           (format port "path = ~a\n"
                   #$(rsync-configuration-share-path config))
           (format port "comment = ~a\n"
                   #$(rsync-configuration-share-comment config))
           (format port "read only = ~a\n"
                   #$(if (rsync-configuration-read-only? config)
                         "true" "false"))
           (format port "timeout = ~a\n"
                   #$(number->string
                      (rsync-configuration-timeout config)))
           #t)))))

(define (rsync-shepherd-service config)
  "Return a <shepherd-service> for rsync with CONFIG."

  (define rsync-command
    #~(list (string-append #$(rsync-configuration-package config) "/bin/rsync")
            "--daemon" "--config" #$(rsync-config-file config)))

  (define pid-file
    (rsync-configuration-pid-file config))

  (define user
    (let ((port (rsync-configuration-port-number config)))
      (if (> port  1024)
          "rsyncd"
          "root")))

  (list (shepherd-service
         (provision '(rsync))
         (documentation "Run rsync daemon.")
         (start #~(make-forkexec-constructor #$rsync-command
                                             #:pid-file #$pid-file
                                             #:user #$user
                                             #:group #$user))
         (stop #~(make-kill-destructor)))))

(define rsync-service-type
  (service-type
   (name 'rsync)
   (extensions
    (list (service-extension shepherd-root-service-type
                             rsync-shepherd-service)
          (service-extension account-service-type
                             (const %rsync-accounts))
          (service-extension activation-service-type
                             rsync-activation)))))

debug log:

solving 9cf2bc89a ...
found 9cf2bc89a in https://yhetil.org/guix-patches/20170728064542.992-1-go.wigust@gmail.com/
found 49c4cb7e2 in https://yhetil.org/guix-patches/20170727220151.2116-1-go.wigust@gmail.com/

applying [1/2] https://yhetil.org/guix-patches/20170727220151.2116-1-go.wigust@gmail.com/
diff --git a/gnu/services/rsync.scm b/gnu/services/rsync.scm
new file mode 100644
index 000000000..49c4cb7e2


applying [2/2] https://yhetil.org/guix-patches/20170728064542.992-1-go.wigust@gmail.com/
diff --git a/gnu/services/rsync.scm b/gnu/services/rsync.scm
index 49c4cb7e2..9cf2bc89a 100644

Checking patch gnu/services/rsync.scm...
Applied patch gnu/services/rsync.scm cleanly.
Checking patch gnu/services/rsync.scm...
Applied patch gnu/services/rsync.scm cleanly.

index at:
100644 9cf2bc89ad589f60de47c4627dcc555ef463d1d1	gnu/services/rsync.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).