Files
romm-startos/docker-images/mariadb/startos-entrypoint.sh
T
alextab93 d6bcfefa5f fix: restore MariaDB definers after backup recovery
Recreate and reset the accounts required by restored RomM views, triggers, and loopback database access before MariaDB accepts network connections.

Release the restore fix as 5.1.0:10.
2026-08-13 11:11:36 -05:00

33 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
set -eu
/usr/local/bin/docker-entrypoint.sh "$@" --skip-networking &
server_pid=$!
trap 'kill -TERM "$server_pid" 2>/dev/null || true; wait "$server_pid"' TERM INT
root_password=''
until {
if mariadb --protocol=socket --user=root --password="$MARIADB_ROOT_PASSWORD" --execute 'SELECT 1' >/dev/null 2>&1; then
root_password="$MARIADB_ROOT_PASSWORD"
elif mariadb --protocol=socket --user=root --password="$MARIADB_PASSWORD" --execute 'SELECT 1' >/dev/null 2>&1; then
root_password="$MARIADB_PASSWORD"
else
false
fi
}; do
if ! kill -0 "$server_pid" 2>/dev/null; then
wait "$server_pid"
exit $?
fi
sleep 1
done
mariadb --protocol=socket --user=root --password="$root_password" --execute "CREATE USER IF NOT EXISTS 'romm'@'%' IDENTIFIED BY '$MARIADB_PASSWORD'; ALTER USER 'romm'@'%' IDENTIFIED BY '$MARIADB_PASSWORD'; GRANT ALL PRIVILEGES ON romm.* TO 'romm'@'%'; CREATE USER IF NOT EXISTS 'romm'@'127.0.0.1' IDENTIFIED BY '$MARIADB_PASSWORD'; ALTER USER 'romm'@'127.0.0.1' IDENTIFIED BY '$MARIADB_PASSWORD'; GRANT ALL PRIVILEGES ON romm.* TO 'romm'@'127.0.0.1';"
kill -TERM "$server_pid"
wait "$server_pid"
exec /usr/local/bin/docker-entrypoint.sh "$@"