@@ -186,8 +186,9 @@ in
186186 preStart =
187187 ''
188188 # Initialise the database.
189− if ! test -e ${cfg.dataDir}; then
189+ if ! test -e ${cfg.dataDir}/PG_VERSION; then
190190 mkdir -m 0700 -p ${cfg.dataDir}
191+ rm -f ${cfg.dataDir}/*.conf
191192 if [ "$(id -u)" = 0 ]; then
192193 chown -R postgres ${cfg.dataDir}
193194 su -s ${pkgs.stdenv.shell} postgres -c 'initdb -U root'
@@ -195,8 +196,6 @@ in
195196 # For non-root operation.
196197 initdb
197198 fi
198− rm -f ${cfg.dataDir}/*.conf
199− touch "${cfg.dataDir}/.first_startup"
200199 fi
201200
202201 ln -sfn "${configFile}" "${cfg.dataDir}/postgresql.conf"