From: Yarl Baudig <yarl-baudig@mailoo.org>
To: 59845@debbugs.gnu.org
Cc: Yarl Baudig <yarl-baudig@mailoo.org>
Subject: [bug#59845] [PATCH 3/4] gnu: Add PMB service.
Date: Mon, 5 Dec 2022 22:52:23 +0100 [thread overview]
Message-ID: <20221205215224.27623-3-yarl-baudig@mailoo.org> (raw)
In-Reply-To: <20221205215224.27623-1-yarl-baudig@mailoo.org>
* gnu/services/ils.scm: New file.
* gnu/local.mk: Add it.
---
gnu/local.mk | 1 +
gnu/services/ils.scm | 128 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 129 insertions(+)
create mode 100644 gnu/services/ils.scm
diff --git a/gnu/local.mk b/gnu/local.mk
index ff0c86584a..16de11e31e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -670,6 +670,7 @@ GNU_SYSTEM_MODULES = \
%D%/services/getmail.scm \
%D%/services/guix.scm \
%D%/services/hurd.scm \
+ %D%/services/ils.scm \
%D%/services/kerberos.scm \
%D%/services/lightdm.scm \
%D%/services/linux.scm \
diff --git a/gnu/services/ils.scm b/gnu/services/ils.scm
new file mode 100644
index 0000000000..16c0dbab22
--- /dev/null
+++ b/gnu/services/ils.scm
@@ -0,0 +1,128 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Yarl Baudig <yarl-baudig@mailoo.org>
+;;;
+;;; 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 ils)
+ #:use-module (gnu services)
+ #:use-module (gnu services web)
+ #:use-module (gnu packages ils)
+ #:use-module (guix records)
+ #:use-module (guix utils)
+ #:use-module (guix gexp)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 format)
+ #:export (pmb-configuration
+ pmb-service-type
+ %default-nginx-pmb-location
+ %default-pmb-php-fpm-configuration
+ %default-pmb-mysql-configuration-extra-content))
+
+;;; Commentary
+;;;
+;;; Integrated Library Systems services.
+;;;
+;;; Code
+
+(define %default-nginx-pmb-location
+ (let ((base (nginx-php-location)))
+ (nginx-location-configuration
+ (inherit base)
+ (body (cons
+ "fastcgi_read_timeout 300;"
+ (nginx-location-configuration-body base))))))
+
+(define %default-pmb-php-fpm-configuration
+ "expose_php=off
+max_execution_time=300
+max_input_vars=50000
+memory_limit=256M
+post_max_size=64M
+upload_max_filesize=64M
+date.timezone=Europe/Paris")
+
+(define %default-pmb-mysql-configuration-extra-content
+ "[server]
+sql_mode=NO_AUTO_CREATE_USER
+collation_server=utf8_unicode_ci
+key_buffer_size=1000001536
+join_buffer_size=4000000")
+
+(define-record-type* <pmb-configuration>
+ pmb-configuration make-pmb-configuration
+ pmb-configuration?
+ (pmb pmb-configuration-pmb (default pmb))
+ (http-directory pmb-configuration-http-directory
+ (default "/srv/http/pmb"))
+ (php-fpm-user pmb-configuration-php-fpm-user
+ (default "php-fpm"))
+ (php-fpm-group pmb-configuration-php-fpm-group
+ (default "php-fpm")))
+
+(define (pmb-activation config)
+ (match-record
+ config
+ <pmb-configuration>
+ (pmb http-directory php-fpm-user php-fpm-group)
+ #~(begin
+ (use-modules (guix build utils))
+ (use-modules (ice-9 ftw))
+ (format #t "Copying pmb '~a' to http directory '~a'~%"
+ (string-append #$pmb "/share/http/pmb")
+ #$http-directory)
+ (mkdir-p #$http-directory)
+ ;; Please be quiet
+ (call-with-output-file "/dev/null"
+ (lambda (port)
+ (with-output-to-port port
+ (lambda ()
+ (copy-recursively (string-append #$pmb "/share/http/pmb")
+ #$http-directory)))))
+ (define (enter? name stat result)
+ #t)
+ (define (lchown obj)
+ (let ((user (getpwnam #$php-fpm-user))
+ (group (getgrnam #$php-fpm-group)))
+ (chown obj (passwd:uid user) (group:gid group))))
+ (define (leaf name stat result)
+ (lchown name)
+ result)
+ (define (down name stat result)
+ (lchown name)
+ result)
+ (define (up name stat result) result)
+ (define (skip name stat result) result)
+ (define (error name stat errno result)
+ (warning (G_ "~a: ~a~%")
+ name (strerror errno))
+ result)
+ (file-system-fold enter? leaf down up skip error '() #$http-directory)
+ ;; Those are to hide installation files on a re-activation
+ (if
+ (file-exists? (string-append #$http-directory "/tables/noinstall.php"))
+ (delete-file (string-append #$http-directory "/tables/install.php")))
+ (if
+ (file-exists? (string-append #$http-directory "/tables/noinstall_rep.php"))
+ (delete-file (string-append #$http-directory "/tables/install_rep.php"))))))
+
+(define pmb-service-type
+ (service-type
+ (name 'guix)
+ (extensions
+ (list (service-extension activation-service-type
+ pmb-activation)))
+ (default-value (pmb-configuration))
+ (description "Install the pmb Integrated Library System")))
--
2.38.1
next prev parent reply other threads:[~2022-12-05 21:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-05 21:48 [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Yarl Baudig
2022-12-05 21:52 ` [bug#59845] [PATCH 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
2022-12-05 21:52 ` [bug#59845] [PATCH 2/4] gnu: Add PMB Yarl Baudig
2022-12-05 21:52 ` Yarl Baudig [this message]
2022-12-05 21:52 ` [bug#59845] [PATCH 4/4] doc: Add Integrated Library System section Yarl Baudig
2022-12-09 11:52 ` [bug#59845] V2 yarl baudig
2022-12-09 11:53 ` [bug#59845] [PATCH v2 1/4] gnu: php: Add '--enable-soap' configure option Yarl Baudig
2022-12-09 11:53 ` [bug#59845] [PATCH v2 2/4] gnu: Add PMB Yarl Baudig
2022-12-20 14:56 ` [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Ludovic Courtès
2022-12-09 11:53 ` [bug#59845] [PATCH v2 3/4] gnu: Add PMB service Yarl Baudig
2022-12-20 15:03 ` [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Ludovic Courtès
2022-12-09 11:53 ` [bug#59845] [PATCH v2 4/4] doc: Add Integrated Library System section Yarl Baudig
2022-12-20 15:13 ` [bug#59845] [PATCH 0/4] Add PMB (Integrated Library System) Ludovic Courtès
2022-12-22 17:18 ` yarl baudig
2022-12-22 22:40 ` Ludovic Courtès
2022-12-23 8:17 ` yarl baudig
2022-12-25 17:26 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221205215224.27623-3-yarl-baudig@mailoo.org \
--to=yarl-baudig@mailoo.org \
--cc=59845@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).