|
@ -25,31 +25,7 @@ fi |
|
|
if ! [ -d "$HOST_DATASTORE/${SERVICE_NAME}$DB_DATADIR" ]; then |
|
|
if ! [ -d "$HOST_DATASTORE/${SERVICE_NAME}$DB_DATADIR" ]; then |
|
|
|
|
|
|
|
|
MYSQL_ROOT_PASSWORD="$(gen_password)" |
|
|
MYSQL_ROOT_PASSWORD="$(gen_password)" |
|
|
|
|
|
|
|
|
debug docker run -e "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" \ |
|
|
|
|
|
--rm \ |
|
|
|
|
|
-v "$DATA_DIR:$DB_DATADIR" \ |
|
|
|
|
|
--entrypoint /bin/bash "$DOCKER_BASE_IMAGE" |
|
|
|
|
|
docker run -e "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" \ |
|
|
|
|
|
--rm \ |
|
|
|
|
|
-v "$DATA_DIR:$DB_DATADIR" \ |
|
|
|
|
|
--entrypoint /bin/bash "$DOCKER_BASE_IMAGE" -c ' |
|
|
|
|
|
mysqld() { |
|
|
|
|
|
echo "diverted mysqld call..." >&2; |
|
|
|
|
|
echo "$*" | grep -E "(--help|--skip-networking)" >/dev/null 2>&1 || return; |
|
|
|
|
|
echo " .. Allowing call." >&2; |
|
|
|
|
|
/usr/sbin/mysqld "$@"; |
|
|
|
|
|
} |
|
|
|
|
|
export -f mysqld; |
|
|
|
|
|
/docker-entrypoint.sh mysqld' || true |
|
|
|
|
|
## docker errorlevel is still 0 even if it failed. |
|
|
|
|
|
## AND we must ignore mysqld error ! |
|
|
|
|
|
[ "$(find "$DATA_DIR" \ |
|
|
|
|
|
-maxdepth 0 -type d -empty 2>/dev/null)" ] && { |
|
|
|
|
|
err "Docker run probably failed to do it's job." |
|
|
|
|
|
exit 1 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mkdir -p "${HOST_DB_PASSFILE%/*}" |
|
|
## XXXvlab: this won't help support multiple project running on the |
|
|
## XXXvlab: this won't help support multiple project running on the |
|
|
## same host |
|
|
## same host |
|
|
cat <<EOF > "$HOST_DB_PASSFILE" |
|
|
cat <<EOF > "$HOST_DB_PASSFILE" |
|
@ -57,5 +33,27 @@ if ! [ -d "$HOST_DATASTORE/${SERVICE_NAME}$DB_DATADIR" ]; then |
|
|
password=$MYSQL_ROOT_PASSWORD |
|
|
password=$MYSQL_ROOT_PASSWORD |
|
|
EOF |
|
|
EOF |
|
|
chmod 600 "$HOST_DB_PASSFILE" |
|
|
chmod 600 "$HOST_DB_PASSFILE" |
|
|
|
|
|
|
|
|
|
|
|
## deactivating final connection check |
|
|
|
|
|
ddb () { true; } |
|
|
|
|
|
export -f ddb |
|
|
|
|
|
ensure_db_docker_running || exit 1 |
|
|
|
|
|
|
|
|
|
|
|
docker exec -i "$_DB_NAME" mysql <<EOF |
|
|
|
|
|
USE mysql; |
|
|
|
|
|
GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION; |
|
|
|
|
|
GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD' WITH GRANT OPTION; |
|
|
|
|
|
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('${MYSQL_ROOT_PASSWORD}'); |
|
|
|
|
|
FLUSH PRIVILEGES; |
|
|
|
|
|
EOF |
|
|
|
|
|
|
|
|
|
|
|
. lib/common |
|
|
|
|
|
|
|
|
|
|
|
err=$(echo "$check_command" | ddb 2>&1 >/dev/null) || { |
|
|
|
|
|
err "Docker run probably failed to do it's job." |
|
|
|
|
|
echo "$err" | prefix " " >&2 |
|
|
|
|
|
exit 1 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
info "New root password for mysql. " |
|
|
info "New root password for mysql. " |
|
|
fi |
|
|
fi |