Skip to content

Commit 0cb10aa

Browse files
committed
Add command to update DB user password to current from file
There was no easy way to do this, besides also completely dropping and recreating an empty database.
1 parent 05e7160 commit 0cb10aa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sql/dj_setup_database.in

+16
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Commands:
2929
status check database installation status
3030
genpass generate DB,API,Symfony,admin password files
3131
create-db-users create (empty) database and users
32+
update-password update DB user database to that in 'etc/dbpasswords.secret'
3233
install create database, example contest and users if not existing
3334
bare-install create database, setup defaults if not existing
3435
uninstall remove database users and database, INCLUDING ALL DATA!
@@ -235,6 +236,17 @@ remove_db_users()
235236
verbose "DOMjudge database and user(s) removed."
236237
}
237238

239+
update_password()
240+
{
241+
read_dbpasswords
242+
(
243+
echo "ALTER USER '$domjudge_DBUSER'@'localhost' IDENTIFIED BY '$domjudge_PASSWD';"
244+
echo "FLUSH PRIVILEGES;"
245+
) | mysql
246+
verbose "ALTER USER '$domjudge_DBUSER'@'localhost' IDENTIFIED BY '$domjudge_PASSWD';"
247+
verbose "Database user password updated from credentials file."
248+
}
249+
238250
install_examples()
239251
{
240252
DBUSER=$domjudge_DBUSER PASSWD=$domjudge_PASSWD symfony_console domjudge:load-example-data
@@ -337,6 +349,10 @@ create-db-users)
337349
create_db_users_helper
338350
;;
339351

352+
update-password)
353+
update_password
354+
;;
355+
340356
bare-install|install)
341357
read_dbpasswords
342358
create_db_users

0 commit comments

Comments
 (0)