Skip to content

Commit d905d75

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 abeefb3 commit d905d75

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sql/dj_setup_database.in

Lines changed: 16 additions & 0 deletions
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!
@@ -233,6 +234,17 @@ remove_db_users()
233234
verbose "DOMjudge database and user(s) removed."
234235
}
235236

237+
update_password()
238+
{
239+
read_dbpasswords
240+
(
241+
echo "ALTER USER '$domjudge_DBUSER'@'localhost' IDENTIFIED BY '$domjudge_PASSWD';"
242+
echo "FLUSH PRIVILEGES;"
243+
) | mysql
244+
verbose "ALTER USER '$domjudge_DBUSER'@'localhost' IDENTIFIED BY '$domjudge_PASSWD';"
245+
verbose "Database user password updated from credentials file."
246+
}
247+
236248
install_examples()
237249
{
238250
DBUSER=$domjudge_DBUSER PASSWD=$domjudge_PASSWD symfony_console domjudge:load-example-data
@@ -335,6 +347,10 @@ create-db-users)
335347
create_db_users_helper
336348
;;
337349

350+
update-password)
351+
update_password
352+
;;
353+
338354
bare-install|install)
339355
read_dbpasswords
340356
create_db_users

0 commit comments

Comments
 (0)