3
0
Fork 0
forked from mirrors/nixpkgs

nixos/postgresql: Fix initdb for existing, empty postgres partitions

This commit is contained in:
William A. Kennington III 2015-07-02 00:08:02 -07:00
parent 54022375eb
commit b21fd5d066

View file

@ -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"