From 4aacc800c33e43629bc41cda7ed44f93f2e642bd Mon Sep 17 00:00:00 2001 From: Jaap Eldering Date: Fri, 22 Nov 2024 14:45:43 +0100 Subject: [PATCH] Some fixes to dump/load DB commands in dj_setup_database: - Don't use sudo: we assume we can access the DB (like in other commands), the user can call this with sudo if necessary. - Fetch DB name from config instead of hardcoded `domjudge`. - Don't exit within case unless with non-zero status. --- sql/dj_setup_database.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/dj_setup_database.in b/sql/dj_setup_database.in index 6bc35b34bf..0bbfe80e20 100755 --- a/sql/dj_setup_database.in +++ b/sql/dj_setup_database.in @@ -254,7 +254,7 @@ create_db_users_helper() } create_database_dump () { - sudo mysqldump $(mysql_options) --opt --skip-lock-tables domjudge | pv | gzip > "$DATABASEDUMPDIR/${1}.sql.gz" + mysqldump $(mysql_options) --opt --skip-lock-tables "$DBNAME" | pv | gzip > "$DATABASEDUMPDIR/${1}.sql.gz" } ### Script starts here ### @@ -392,8 +392,7 @@ dump) esac done fi - create_database_dump $DUMPNAME - exit 0 + create_database_dump "$DUMPNAME" ;; load) @@ -434,9 +433,10 @@ load) exit 1 fi + read_dbpasswords uninstall_helper create_db_users_helper - pv "${FILE}" | gunzip | mysql domjudge + pv "${FILE}" | gunzip | mysql "$DBNAME" ;; *)