Skip to content

Commit

Permalink
Add command to update DB user password to current from file
Browse files Browse the repository at this point in the history
There was no easy way to do this, besides also completely
dropping and recreating an empty database.
  • Loading branch information
eldering committed Aug 25, 2024
1 parent 05e7160 commit 0cb10aa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sql/dj_setup_database.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Commands:
status check database installation status
genpass generate DB,API,Symfony,admin password files
create-db-users create (empty) database and users
update-password update DB user database to that in 'etc/dbpasswords.secret'
install create database, example contest and users if not existing
bare-install create database, setup defaults if not existing
uninstall remove database users and database, INCLUDING ALL DATA!
Expand Down Expand Up @@ -235,6 +236,17 @@ remove_db_users()
verbose "DOMjudge database and user(s) removed."
}

update_password()
{
read_dbpasswords
(
echo "ALTER USER '$domjudge_DBUSER'@'localhost' IDENTIFIED BY '$domjudge_PASSWD';"
echo "FLUSH PRIVILEGES;"
) | mysql
verbose "ALTER USER '$domjudge_DBUSER'@'localhost' IDENTIFIED BY '$domjudge_PASSWD';"
verbose "Database user password updated from credentials file."
}

install_examples()
{
DBUSER=$domjudge_DBUSER PASSWD=$domjudge_PASSWD symfony_console domjudge:load-example-data
Expand Down Expand Up @@ -337,6 +349,10 @@ create-db-users)
create_db_users_helper
;;

update-password)
update_password
;;

bare-install|install)
read_dbpasswords
create_db_users
Expand Down

0 comments on commit 0cb10aa

Please sign in to comment.