Skip to content

Commit 4aacc80

Browse files
committed
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.
1 parent 1885c3f commit 4aacc80

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sql/dj_setup_database.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ create_db_users_helper()
254254
}
255255

256256
create_database_dump () {
257-
sudo mysqldump $(mysql_options) --opt --skip-lock-tables domjudge | pv | gzip > "$DATABASEDUMPDIR/${1}.sql.gz"
257+
mysqldump $(mysql_options) --opt --skip-lock-tables "$DBNAME" | pv | gzip > "$DATABASEDUMPDIR/${1}.sql.gz"
258258
}
259259

260260
### Script starts here ###
@@ -392,8 +392,7 @@ dump)
392392
esac
393393
done
394394
fi
395-
create_database_dump $DUMPNAME
396-
exit 0
395+
create_database_dump "$DUMPNAME"
397396
;;
398397

399398
load)
@@ -434,9 +433,10 @@ load)
434433
exit 1
435434
fi
436435

436+
read_dbpasswords
437437
uninstall_helper
438438
create_db_users_helper
439-
pv "${FILE}" | gunzip | mysql domjudge
439+
pv "${FILE}" | gunzip | mysql "$DBNAME"
440440
;;
441441

442442
*)

0 commit comments

Comments
 (0)