From b21fd5d066baadb06ca8e9a2accfcb4e94c60a09 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Thu, 2 Jul 2015 00:08:02 -0700 Subject: [PATCH] nixos/postgresql: Fix initdb for existing, empty postgres partitions --- nixos/modules/services/databases/postgresql.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix index 328e864ced38..97927055ce37 100644 --- a/nixos/modules/services/databases/postgresql.nix +++ b/nixos/modules/services/databases/postgresql.nix @@ -186,8 +186,9 @@ in preStart = '' # Initialise the database. - if ! test -e ${cfg.dataDir}; then + if ! test -e ${cfg.dataDir}/PG_VERSION; then mkdir -m 0700 -p ${cfg.dataDir} + rm -f ${cfg.dataDir}/*.conf if [ "$(id -u)" = 0 ]; then chown -R postgres ${cfg.dataDir} su -s ${pkgs.stdenv.shell} postgres -c 'initdb -U root' @@ -195,8 +196,6 @@ in # For non-root operation. initdb fi - rm -f ${cfg.dataDir}/*.conf - touch "${cfg.dataDir}/.first_startup" fi ln -sfn "${configFile}" "${cfg.dataDir}/postgresql.conf"