Skip to content

Commit

Permalink
Updating sql-server docker entrypoint script to update root superuser…
Browse files Browse the repository at this point in the history
… accounts based on DOLT_ROOT_HOST and DOLT_ROOT_PASSWORD
  • Loading branch information
fulghum committed Jan 14, 2025
1 parent b095b72 commit d1ef725
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,18 @@ _main() {

# If DOLT_ROOT_HOST has been specified – create a root user for that host with the specified password
if [ -n "$DOLT_ROOT_HOST" ] && [ "$DOLT_ROOT_HOST" != 'localhost' ]; then
dolt sql -q "CREATE USER IF NOT EXISTS 'root'@'${DOLT_ROOT_HOST}' IDENTIFIED BY '${DOLT_ROOT_PASSWORD}';
echo "Ensuring root@{$DOLT_ROOT_HOST} superuser exists (DOLT_ROOT_HOST was specified)"
dolt -u root -p ${DOLT_ROOT_PASSWORD} sql -q "
CREATE USER IF NOT EXISTS 'root'@'${DOLT_ROOT_HOST}' IDENTIFIED BY '${DOLT_ROOT_PASSWORD}';
ALTER USER 'root'@'${DOLT_ROOT_HOST}' IDENTIFIED BY '${DOLT_ROOT_PASSWORD}';
GRANT ALL ON *.* TO 'root'@'${DOLT_ROOT_HOST}' WITH GRANT OPTION;"
fi

# Ensure the root@localhost user exists, with the correct, requested password
# Ensure the root@localhost user exists, with the requested password
echo "Ensuring root@localhost user exists"
dolt sql -q "CREATE USER IF NOT EXISTS 'root'@'localhost' IDENTIFIED BY '${DOLT_ROOT_PASSWORD}';
ALTER USER 'root'@'localhost' IDENTIFIED BY '${DOLT_ROOT_PASSWORD}';"
ALTER USER 'root'@'localhost' IDENTIFIED BY '${DOLT_ROOT_PASSWORD}';
GRANT ALL ON *.* TO 'root'@'localhost' WITH GRANT OPTION;"

if [[ ! -f $INIT_COMPLETED ]]; then
# run any file provided in /docker-entrypoint-initdb.d directory before the server starts
Expand Down

0 comments on commit d1ef725

Please sign in to comment.