Skip to content

Commit

Permalink
Some fixes to dump/load DB commands in dj_setup_database:
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
eldering committed Nov 22, 2024
1 parent 1885c3f commit 4aacc80
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sql/dj_setup_database.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand Down Expand Up @@ -392,8 +392,7 @@ dump)
esac
done
fi
create_database_dump $DUMPNAME
exit 0
create_database_dump "$DUMPNAME"
;;

load)
Expand Down Expand Up @@ -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"
;;

*)
Expand Down

0 comments on commit 4aacc80

Please sign in to comment.