Add the mysql need: its own database on the Core's MariaDB

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>
This commit is contained in:
2026-12-03 15:15:23 -07:00
co-authored by Claude Opus 5.5
parent 6ab1db839b
commit 8ef2112e3c
12 changed files with 93 additions and 14 deletions
+9 -6
View File
@@ -3,7 +3,7 @@
# Purpose : Make, deploy and test apps for Federated Core, against the Core
# in coreapp-dev's VM (coreapp-vm).
#
# coreapp new [--postgres] [--sso] [--email] <name>
# coreapp new [--postgres | --mysql] [--sso] [--email] <name>
# make a new app in ./<name> (with its own database,
# sign-in through the Core's Authelia, sending mail)
# coreapp deploy [--recreate]
@@ -154,20 +154,22 @@ apply_overlay() {
}
cmd_new() {
local name="" postgres="" sso="" email="" title dbname f needs="" what=""
local name="" postgres="" mysql="" sso="" email="" title dbname f needs="" what=""
local overlays=()
while [[ $# -gt 0 ]]; do
case "$1" in
--postgres) postgres=1 ;;
--mysql) mysql=1 ;;
--sso) sso=1 ;;
--email) email=1 ;;
-*) die "Unknown option $1. Usage: coreapp new [--postgres] [--sso] [--email] <name>" ;;
-*) die "Unknown option $1. Usage: coreapp new [--postgres | --mysql] [--sso] [--email] <name>" ;;
*) name="$1" ;;
esac
shift
done
[[ -d "$TEMPLATE" ]] || die "The app template is missing: $TEMPLATE"
[[ -n "$name" ]] || die "Usage: coreapp new [--postgres] [--sso] [--email] <name> (lowercase letters, digits and -)"
[[ -n "$name" ]] || die "Usage: coreapp new [--postgres | --mysql] [--sso] [--email] <name> (lowercase letters, digits and -)"
[[ -z "$postgres" || -z "$mysql" ]] || die "--postgres or --mysql, not both."
[[ "$name" =~ ^[a-z]([a-z0-9-]{0,29}[a-z0-9])$ ]] \
|| die "'$name': use 2-31 lowercase letters, digits and -, starting with a letter and not ending with -. It becomes https://$name.<domain>."
[[ ! -e "$name" ]] || die "./$name already exists."
@@ -190,7 +192,8 @@ cmd_new() {
apply_overlay "$name" "$f"
[[ -f "$f/.needs" ]] && needs="$needs, \"$(cat "$f/.needs")\""
done
# No example app for email: the settings are in README.md
# No example apps for mysql and email: the settings are in README.md
[[ -n "$mysql" ]] && needs="\"mysql\"$needs"
[[ -n "$email" ]] && needs="$needs, \"email\""
sed -i "s/^needs = .*/needs = [${needs#, }]/" "$name/coreapp.toml"
# The example apps with a database or sign-in have a /health path
@@ -200,7 +203,7 @@ cmd_new() {
sed -i -e "s/{{NAME}}/$name/g" -e "s/{{TITLE}}/$title/g" -e "s/{{DBNAME}}/$dbname/g" "$f"
done < <(find "$name" -type f ! -name '*.png' -print0)
[[ -n "$postgres" ]] && what=", with a database"
[[ -n "$postgres$mysql" ]] && what=", with a database"
[[ -n "$sso" ]] && what="$what, with sign-in through Authelia"
[[ -n "$email" ]] && what="$what, sending mail"
echo "Made $title in ./$name$what."