You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
884 B

#!/bin/bash
set -e
mysql_log() {
local type="$1"; shift
printf '%s [%s] [Entrypoint]: %s\n' "$(date --rfc-3339=seconds)" "$type" "$*"
}
mysql_note() {
mysql_log Note "$@"
}
docker_change_passw() {
echo "Creo la base de datos si no existe ${MYSQL_DATABSE}"
echo "CREATE DATABASE IF NOT EXISTS ${MYSQL_DATABASE}" | mysql -u root
echo "Reseteo la configuracion de usuario ${MYSQL_USER}"
echo "CREATE USER IF NOT EXISTS '${MYSQL_USER}'@'%' IDENTIFIED BY '${MYSQL_PASSWORD}' ; GRANT ALL ON ${MYSQL_DATABASE}.* TO '${MYSQL_USER}'@'%' WITH GRANT OPTION ;" | mysql -u root
mysqladmin shutdown
}
docker_temp_server_start() {
echo "Arranco temporalmente MariaDB para crear la base de datos ${MYSQL_DATABASE} y el usuario ${MYSQL_USER}"
echo "Running with user"
whoami
mysqld_safe &
sleep 6
docker_change_passw
}
docker_temp_server_start
echo "Iniciando el servidor"
exec "$@"