forked from mirrors/nixpkgs
nixos/postgresql: Fix initdb for existing, empty postgres partitions
This commit is contained in:
parent
54022375eb
commit
b21fd5d066
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue