Merge branch 'revert-postgres-superuser'

The recent postgres superuser changes have caused a lot of breakages to
existing systems, and we are very close to branching for the 14.04
stable release. We can bring this back after.
This commit is contained in:
Shea Levy 2014-04-11 19:24:22 -04:00
commit c47d3bb600

View File

@ -190,14 +190,13 @@ in
mkdir -m 0700 -p ${cfg.dataDir} mkdir -m 0700 -p ${cfg.dataDir}
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
chown -R postgres ${cfg.dataDir} chown -R postgres ${cfg.dataDir}
su -s ${pkgs.stdenv.shell} postgres -c initdb su -s ${pkgs.stdenv.shell} postgres -c 'initdb -U root'
else else
# For non-root operation. # For non-root operation.
initdb initdb
fi fi
rm -f ${cfg.dataDir}/*.conf rm -f ${cfg.dataDir}/*.conf
touch "${cfg.dataDir}/.first_startup" touch "${cfg.dataDir}/.first_startup"
touch "${cfg.dataDir}/postgresql-user-created"
fi fi
ln -sfn "${configFile}" "${cfg.dataDir}/postgresql.conf" ln -sfn "${configFile}" "${cfg.dataDir}/postgresql.conf"
@ -226,19 +225,14 @@ in
# Wait for PostgreSQL to be ready to accept connections. # Wait for PostgreSQL to be ready to accept connections.
postStart = postStart =
'' ''
while ! ${pkgs.postgresql93}/bin/pg_isready > /dev/null; do while ! psql postgres -c "" 2> /dev/null; do
if ! kill -0 "$MAINPID"; then exit 1; fi if ! kill -0 "$MAINPID"; then exit 1; fi
sleep 0.1 sleep 0.1
done done
if ! [ -e ${cfg.dataDir}/postgresql-user-created ]; then
createuser --superuser postgres
touch ${cfg.dataDir}/postgresql-user-created
fi
if test -e "${cfg.dataDir}/.first_startup"; then if test -e "${cfg.dataDir}/.first_startup"; then
${optionalString (cfg.initialScript != null) '' ${optionalString (cfg.initialScript != null) ''
cat "${cfg.initialScript}" | su -s ${pkgs.stdenv.shell} postgres -c 'psql postgres' cat "${cfg.initialScript}" | psql postgres
''} ''}
rm -f "${cfg.dataDir}/.first_startup" rm -f "${cfg.dataDir}/.first_startup"
fi fi