needs = ["mysql"] (coreapp new --mysql) makes a user and database coreapp_<name> on pdnsmysql, with the same DB_* settings as postgres (so an app has one or the other). Root's password is read inside the container, so it stays out of installapp's set -x log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
14 lines
830 B
Plaintext
14 lines
830 B
Plaintext
# Its own database and user on the Core's MariaDB (pdnsmysql, shared with
|
|
# PowerDNS and Federated's apps), with the password from .env. Safe to run
|
|
# again: an existing user gets the password, an existing database is kept.
|
|
# Root's password is read inside the container (its MYSQL_ROOT_PASSWORD), so
|
|
# it's not on a command line or in installapp's set -x log.
|
|
DB_PASSWORD="$(sed -n 's/^DB_PASSWORD=//p' /federated/apps/{{NAME}}/.env)"
|
|
docker exec -i pdnsmysql sh -c 'MYSQL_PWD="$MYSQL_ROOT_PASSWORD" exec mariadb -uroot' <<SQL
|
|
CREATE USER IF NOT EXISTS '{{DBNAME}}'@'%' IDENTIFIED BY '$DB_PASSWORD';
|
|
ALTER USER '{{DBNAME}}'@'%' IDENTIFIED BY '$DB_PASSWORD';
|
|
CREATE DATABASE IF NOT EXISTS {{DBNAME}} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
GRANT ALL PRIVILEGES ON {{DBNAME}}.* TO '{{DBNAME}}'@'%';
|
|
SQL
|
|
unset DB_PASSWORD
|