services: postgresql: Add locale to configuration
* gnu/services/databases.scm (<postgresql-configuration>): Add locale field. (postgresql-shepherd-service): Pass locale to initdb. (postgresql-service): Add locale default. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
2d3d5cc5ea
commit
e05b780a58
@ -10167,13 +10167,13 @@ The @code{(gnu services databases)} module provides the following services.
|
|||||||
|
|
||||||
@deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
|
@deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
|
||||||
[#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
|
[#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
|
||||||
[#:port 5432]
|
[#:port 5432] [#:locale ``en_US.utf8'']
|
||||||
Return a service that runs @var{postgresql}, the PostgreSQL database
|
Return a service that runs @var{postgresql}, the PostgreSQL database
|
||||||
server.
|
server.
|
||||||
|
|
||||||
The PostgreSQL daemon loads its runtime configuration from
|
The PostgreSQL daemon loads its runtime configuration from @var{config-file},
|
||||||
@var{config-file}, stores the database cluster in @var{data-directory} and
|
creates a database cluster with @var{locale} as the default
|
||||||
listens on @var{port}.
|
locale, stored in @var{data-directory}. It then listens on @var{port}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
|
@deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
(default postgresql))
|
(default postgresql))
|
||||||
(port postgresql-configuration-port
|
(port postgresql-configuration-port
|
||||||
(default 5432))
|
(default 5432))
|
||||||
|
(locale postgresql-configuration-locale
|
||||||
|
(default "en_US.utf8"))
|
||||||
(config-file postgresql-configuration-file)
|
(config-file postgresql-configuration-file)
|
||||||
(data-directory postgresql-configuration-data-directory))
|
(data-directory postgresql-configuration-data-directory))
|
||||||
|
|
||||||
@ -82,13 +84,18 @@ host all all ::1/128 trust"))
|
|||||||
|
|
||||||
(define postgresql-activation
|
(define postgresql-activation
|
||||||
(match-lambda
|
(match-lambda
|
||||||
(($ <postgresql-configuration> postgresql port config-file data-directory)
|
(($ <postgresql-configuration> postgresql port locale config-file data-directory)
|
||||||
#~(begin
|
#~(begin
|
||||||
(use-modules (guix build utils)
|
(use-modules (guix build utils)
|
||||||
(ice-9 match))
|
(ice-9 match))
|
||||||
|
|
||||||
(let ((user (getpwnam "postgres"))
|
(let ((user (getpwnam "postgres"))
|
||||||
(initdb (string-append #$postgresql "/bin/initdb")))
|
(initdb (string-append #$postgresql "/bin/initdb"))
|
||||||
|
(initdb-args
|
||||||
|
(append
|
||||||
|
(if #$locale
|
||||||
|
(list (string-append "--locale=" #$locale))
|
||||||
|
'()))))
|
||||||
;; Create db state directory.
|
;; Create db state directory.
|
||||||
(mkdir-p #$data-directory)
|
(mkdir-p #$data-directory)
|
||||||
(chown #$data-directory (passwd:uid user) (passwd:gid user))
|
(chown #$data-directory (passwd:uid user) (passwd:gid user))
|
||||||
@ -103,14 +110,19 @@ host all all ::1/128 trust"))
|
|||||||
(lambda ()
|
(lambda ()
|
||||||
(setgid (passwd:gid user))
|
(setgid (passwd:gid user))
|
||||||
(setuid (passwd:uid user))
|
(setuid (passwd:uid user))
|
||||||
(primitive-exit (system* initdb "-D" #$data-directory)))
|
(primitive-exit
|
||||||
|
(apply system*
|
||||||
|
initdb
|
||||||
|
"-D"
|
||||||
|
#$data-directory
|
||||||
|
initdb-args)))
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(primitive-exit 1))))
|
(primitive-exit 1))))
|
||||||
(pid (waitpid pid))))))))
|
(pid (waitpid pid))))))))
|
||||||
|
|
||||||
(define postgresql-shepherd-service
|
(define postgresql-shepherd-service
|
||||||
(match-lambda
|
(match-lambda
|
||||||
(($ <postgresql-configuration> postgresql port config-file data-directory)
|
(($ <postgresql-configuration> postgresql port locale config-file data-directory)
|
||||||
(let ((start-script
|
(let ((start-script
|
||||||
;; Wrapper script that switches to the 'postgres' user before
|
;; Wrapper script that switches to the 'postgres' user before
|
||||||
;; launching daemon.
|
;; launching daemon.
|
||||||
@ -144,6 +156,7 @@ host all all ::1/128 trust"))
|
|||||||
|
|
||||||
(define* (postgresql-service #:key (postgresql postgresql)
|
(define* (postgresql-service #:key (postgresql postgresql)
|
||||||
(port 5432)
|
(port 5432)
|
||||||
|
(locale "en_US.utf8")
|
||||||
(config-file %default-postgres-config)
|
(config-file %default-postgres-config)
|
||||||
(data-directory "/var/lib/postgresql/data"))
|
(data-directory "/var/lib/postgresql/data"))
|
||||||
"Return a service that runs @var{postgresql}, the PostgreSQL database server.
|
"Return a service that runs @var{postgresql}, the PostgreSQL database server.
|
||||||
@ -154,6 +167,7 @@ and stores the database cluster in @var{data-directory}."
|
|||||||
(postgresql-configuration
|
(postgresql-configuration
|
||||||
(postgresql postgresql)
|
(postgresql postgresql)
|
||||||
(port port)
|
(port port)
|
||||||
|
(locale locale)
|
||||||
(config-file config-file)
|
(config-file config-file)
|
||||||
(data-directory data-directory))))
|
(data-directory data-directory))))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user