#!/bin/sh # Idempotent HarborForge DB bootstrap. Runs on every `compose up` via the # hf_db_init sidecar service: waits for mysql to accept connections, then # ensures the HarborForge database exists and the shared app user can use it. set -e HF_DB_NAME="${HF_DB_NAME:-harborforge}" MYSQL_HOST="${MYSQL_HOST:-mysql}" echo "hf_db_init: waiting for mysql at ${MYSQL_HOST}..." until mysql -h"${MYSQL_HOST}" -uroot -p"${MYSQL_ROOT_PASSWORD}" -e "SELECT 1" >/dev/null 2>&1; do sleep 2 done echo "hf_db_init: ensuring database '${HF_DB_NAME}' exists and granting access to '${DB_USER}'" mysql -h"${MYSQL_HOST}" -uroot -p"${MYSQL_ROOT_PASSWORD}" <