Permalink
Browse files

Use "-v ON_ERROR_STOP=1" when invoking psql to make sure errors are n…

…ot suppressed.
  • Loading branch information...
1 parent 9e4b7b5 commit fe7be8c6cd24fa72d8c22c33598c5549b41771e9 @mo mo committed Mar 21, 2013
Showing with 11 additions and 11 deletions.
  1. +3 −3 installation/admin.py
  2. +6 −6 installation/database.py
  3. +2 −2 uninstall.py
View
@@ -70,22 +70,22 @@ def install(data):
def adapt(value): return psycopg2.extensions.adapt(value).getquoted()
- process.check_input(["su", "-s", "/bin/sh", "-c", "psql -q -f -", installation.system.username],
+ process.check_input(["su", "-s", "/bin/sh", "-c", "psql -q -v ON_ERROR_STOP=1 -f -", installation.system.username],
stdin=("""INSERT INTO users (name, email, password, fullname, status)
VALUES (%s, %s, %s, %s, 'current');"""
% (adapt(username),
adapt(email),
adapt(password),
adapt(fullname))))
- process.check_input(["su", "-s", "/bin/sh", "-c", "psql -q -f -", installation.system.username],
+ process.check_input(["su", "-s", "/bin/sh", "-c", "psql -q -v ON_ERROR_STOP=1 -f -", installation.system.username],
stdin=("""INSERT INTO userroles (uid, role)
SELECT id, 'administrator'
FROM users
WHERE name=%s;"""
% adapt(username)))
- process.check_input(["su", "-s", "/bin/sh", "-c", "psql -q -f -", installation.system.username],
+ process.check_input(["su", "-s", "/bin/sh", "-c", "psql -q -v ON_ERROR_STOP=1 -f -", installation.system.username],
stdin=("""INSERT INTO userroles (uid, role)
SELECT id, 'repositories'
FROM users
View
@@ -102,10 +102,10 @@ def install(data):
# Set cwd to something that Critic system / "postgres" users has access to.
os.chdir(tempfile.gettempdir())
- process.check_output(["su", "-c", "psql -c 'CREATE USER \"%s\";'" % installation.system.username, "postgres"])
+ process.check_output(["su", "-c", "psql -v ON_ERROR_STOP=1 -c 'CREATE USER \"%s\";'" % installation.system.username, "postgres"])
user_created = True
- process.check_output(["su", "-c", "psql -c 'CREATE DATABASE \"critic\";'", "postgres"])
+ process.check_output(["su", "-c", "psql -v ON_ERROR_STOP=1 -c 'CREATE DATABASE \"critic\";'", "postgres"])
database_created = True
try:
@@ -119,7 +119,7 @@ def install(data):
# since they define PL/pgSQL functions.
pass
- process.check_output(["su", "-c", "psql -c 'GRANT ALL ON DATABASE \"critic\" TO \"%s\";'" % installation.system.username, "postgres"])
+ process.check_output(["su", "-c", "psql -v ON_ERROR_STOP=1 -c 'GRANT ALL ON DATABASE \"critic\" TO \"%s\";'" % installation.system.username, "postgres"])
psql_import(os.path.join(root_dir, "dbschema.sql"))
psql_import(os.path.join(root_dir, "dbschema.comments.sql"))
psql_import(os.path.join(root_dir, "comments.pgsql"))
@@ -129,7 +129,7 @@ def install(data):
def adapt(value): return psycopg2.extensions.adapt(value).getquoted()
- process.check_input(["su", "-s", "/bin/sh", "-c", "psql -q -f -", installation.system.username],
+ process.check_input(["su", "-s", "/bin/sh", "-c", "psql -q -v ON_ERROR_STOP=1 -f -", installation.system.username],
stdin=("""INSERT INTO systemidentities (key, name, url_prefix, description)
VALUES ('main', 'main', %s, 'Main');"""
% adapt("http://%s" % installation.system.hostname)))
@@ -143,6 +143,6 @@ def undo():
if language_created:
process.check_output(["su", "-c", "droplang plpgsql critic", "postgres"])
if database_created:
- process.check_output(["su", "-c", "psql -c 'DROP DATABASE \"critic\";'", "postgres"])
+ process.check_output(["su", "-c", "psql -v ON_ERROR_STOP=1 -c 'DROP DATABASE \"critic\";'", "postgres"])
if user_created:
- process.check_output(["su", "-c", "psql -c 'DROP USER \"%s\";'" % installation.system.username, "postgres"])
+ process.check_output(["su", "-c", "psql -v ON_ERROR_STOP=1 -c 'DROP USER \"%s\";'" % installation.system.username, "postgres"])
View
@@ -126,8 +126,8 @@ def main():
# with sudo which makes the command run with the postgres user's homedir as cwd instead.
# This avoids a harmless but pointless error message "could not change directory to X" when the
# /usr/bin/psql perl script tries to chdir back to the previous cwd after doing some stuff.
- run_command(arguments, ["sudo", "-u", "postgres", "-i", "psql", "-c", "DROP DATABASE IF EXISTS %s;" % configuration.database.PARAMETERS["database"]])
- run_command(arguments, ["sudo", "-u", "postgres", "-i", "psql", "-c", "DROP ROLE IF EXISTS %s;" % configuration.database.PARAMETERS["user"]])
+ run_command(arguments, ["sudo", "-u", "postgres", "-i", "psql", "-v", "ON_ERROR_STOP=1", "-c", "DROP DATABASE IF EXISTS %s;" % configuration.database.PARAMETERS["database"]])
+ run_command(arguments, ["sudo", "-u", "postgres", "-i", "psql", "-v", "ON_ERROR_STOP=1", "-c", "DROP ROLE IF EXISTS %s;" % configuration.database.PARAMETERS["user"]])
for user in users_to_delete:
run_command(arguments, ["deluser", "--system", user])

0 comments on commit fe7be8c

Please sign in to comment.