GNU logs - #36451, boring messages


Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#36451] [PATCH] gnu: services: postgresql: Don't initdb when directory exists
Resent-From: Robert Vollmert <rob@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Sun, 30 Jun 2019 20:57:03 +0000
Resent-Message-ID: <handler.36451.B.156192821624041 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 36451
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 36451 <at> debbugs.gnu.org
Cc: Robert Vollmert <rob@HIDDEN>
X-Debbugs-Original-To: guix-patches@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.156192821624041
          (code B ref -1); Sun, 30 Jun 2019 20:57:03 +0000
Received: (at submit) by debbugs.gnu.org; 30 Jun 2019 20:56:56 +0000
Received: from localhost ([127.0.0.1]:47361 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hhgsa-0006Fh-4R
	for submit <at> debbugs.gnu.org; Sun, 30 Jun 2019 16:56:56 -0400
Received: from lists.gnu.org ([209.51.188.17]:54105)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rob@HIDDEN>) id 1hhgsY-0006FV-Hd
 for submit <at> debbugs.gnu.org; Sun, 30 Jun 2019 16:56:54 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:37988)
 by lists.gnu.org with esmtp (Exim 4.86_2)
 (envelope-from <rob@HIDDEN>) id 1hhgsW-0002gu-Pw
 for guix-patches@HIDDEN; Sun, 30 Jun 2019 16:56:54 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rob@HIDDEN>) id 1hhgsU-0001ky-0D
 for guix-patches@HIDDEN; Sun, 30 Jun 2019 16:56:51 -0400
Received: from mx1.mailbox.org ([80.241.60.212]:34076)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <rob@HIDDEN>) id 1hhgsT-0001gs-Bx
 for guix-patches@HIDDEN; Sun, 30 Jun 2019 16:56:49 -0400
Received: from smtp2.mailbox.org (smtp2.mailbox.org
 [IPv6:2001:67c:2050:105:465:1:2:0])
 (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
 (No client certificate requested)
 by mx1.mailbox.org (Postfix) with ESMTPS id A92745034E;
 Sun, 30 Jun 2019 22:56:46 +0200 (CEST)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp2.mailbox.org ([80.241.60.241])
 by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de
 [80.241.56.116]) (amavisd-new, port 10030)
 with ESMTP id ObQnP6pi6EQw; Sun, 30 Jun 2019 22:56:45 +0200 (CEST)
From: Robert Vollmert <rob@HIDDEN>
Date: Sun, 30 Jun 2019 22:56:42 +0200
Message-Id: <20190630205642.54866-1-rob@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 80.241.60.212
X-Spam-Score: -1.6 (-)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

* gnu/services/databases.scm (postgresql-activation): Check if
directory exists.
---
 gnu/services/databases.scm | 63 +++++++++++++++++++-------------------
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index ec31489d48..6b04ae0a0f 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -196,37 +196,38 @@ host	all	all	::1/128 	md5"))
          (use-modules (guix build utils)
                       (ice-9 match))
=20
-         (let ((user (getpwnam "postgres"))
-               (initdb (string-append #$(final-postgresql postgresql ext=
ension-packages)
-                                      "/bin/initdb"))
-               (initdb-args
-                (append
-                 (if #$locale
-                     (list (string-append "--locale=3D" #$locale))
-                     '()))))
-           ;; Create db state directory.
-           (mkdir-p #$data-directory)
-           (chown #$data-directory (passwd:uid user) (passwd:gid user))
-
-           ;; Drop privileges and init state directory in a new
-           ;; process.  Wait for it to finish before proceeding.
-           (match (primitive-fork)
-             (0
-              ;; Exit with a non-zero status code if an exception is thr=
own.
-              (dynamic-wind
-                (const #t)
-                (lambda ()
-                  (setgid (passwd:gid user))
-                  (setuid (passwd:uid user))
-                  (primitive-exit
-                   (apply system*
-                          initdb
-                          "-D"
-                          #$data-directory
-                          initdb-args)))
-                (lambda ()
-                  (primitive-exit 1))))
-             (pid (waitpid pid))))))))
+         (when (not (file-exists? #$data-directory))
+           (let ((user (getpwnam "postgres"))
+                 (initdb (string-append #$(final-postgresql postgresql e=
xtension-packages)
+                                        "/bin/initdb"))
+                 (initdb-args
+                  (append
+                   (if #$locale
+                       (list (string-append "--locale=3D" #$locale))
+                       '()))))
+             ;; Create db state directory.
+             (mkdir-p #$data-directory)
+             (chown #$data-directory (passwd:uid user) (passwd:gid user)=
)
+
+             ;; Drop privileges and init state directory in a new
+             ;; process.  Wait for it to finish before proceeding.
+             (match (primitive-fork)
+               (0
+                ;; Exit with a non-zero status code if an exception is t=
hrown.
+                (dynamic-wind
+                  (const #t)
+                  (lambda ()
+                    (setgid (passwd:gid user))
+                    (setuid (passwd:uid user))
+                    (primitive-exit
+                     (apply system*
+                            initdb
+                            "-D"
+                            #$data-directory
+                            initdb-args)))
+                  (lambda ()
+                    (primitive-exit 1))))
+               (pid (waitpid pid)))))))))
=20
 (define postgresql-shepherd-service
   (match-lambda
--=20
2.20.1 (Apple Git-117)





Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Robert Vollmert <rob@HIDDEN>
Subject: bug#36451: Acknowledgement ([PATCH] gnu: services: postgresql:
 Don't initdb when directory exists)
Message-ID: <handler.36451.B.156192821624041.ack <at> debbugs.gnu.org>
References: <20190630205642.54866-1-rob@HIDDEN>
X-Gnu-PR-Message: ack 36451
X-Gnu-PR-Package: guix-patches
X-Gnu-PR-Keywords: patch
Reply-To: 36451 <at> debbugs.gnu.org
Date: Sun, 30 Jun 2019 20:57:05 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 guix-patches@HIDDEN

If you wish to submit further information on this problem, please
send it to 36451 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
36451: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D36451
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems



Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.