Let an installed app drop a need
Taking sso or email out of needs removes the client or mail account once the new version answers; postgres or mysql need --drop-database (coreapp deploy asks for the app's name). Their settings leave .env first, so a postgres -> mysql switch gets mysql's own values; a failed update rolls back with them intact. The route wait now compares traefik's answer with the app's own, so an app's 404 isn't taken for a missing route. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+26
-10
@@ -6,9 +6,12 @@
|
||||
# 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]
|
||||
# coreapp deploy [--recreate] [--drop-database]
|
||||
# build, copy to the Core, install or update
|
||||
# (--recreate: a new container even if nothing changed)
|
||||
# (--recreate: a new container even if nothing
|
||||
# changed; --drop-database: allow dropping
|
||||
# "postgres" or "mysql" from needs, which deletes
|
||||
# the app's database; asks first)
|
||||
# coreapp check the app answers at https://<name>.<domain>/
|
||||
# coreapp status its container, address and URL
|
||||
# coreapp logs [-f] its log
|
||||
@@ -239,12 +242,15 @@ cmd_new() {
|
||||
# --- deploy -----------------------------------------------------------------
|
||||
|
||||
cmd_deploy() {
|
||||
local plan state tier answer local_id core_id addon="" recreate=""
|
||||
case "${1:-}" in
|
||||
--recreate) recreate=--recreate ;;
|
||||
"") ;;
|
||||
*) die "Usage: coreapp deploy [--recreate]" ;;
|
||||
esac
|
||||
local plan state tier answer local_id core_id dropped addon="" recreate="" dropdb=""
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--recreate) recreate=--recreate ;;
|
||||
--drop-database) dropdb=--drop-database ;;
|
||||
*) die "Usage: coreapp deploy [--recreate] [--drop-database]" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
load_app
|
||||
# (The installer tells about an icon it can't use)
|
||||
[[ "$ICON" != ok || -z "$ICON_NOTE" ]] || echo "Note: $ICON_NOTE"
|
||||
@@ -252,9 +258,19 @@ cmd_deploy() {
|
||||
echo "Updating the installer on the Core ($REMOTE_INSTALLER)..."
|
||||
sync_installer
|
||||
# What installing would do (and whether the Core refuses it: name taken...)
|
||||
plan="$(installer plan)" || exit 1
|
||||
plan="$(installer plan $dropdb)" || exit 1
|
||||
state="$(sed -n 's/^state=//p' <<< "$plan")"
|
||||
tier="$(sed -n 's/^tier=//p' <<< "$plan")"
|
||||
dropped="$(sed -n 's/^dropped_needs=//p' <<< "$plan")"
|
||||
if [[ -n "$dropped" ]]; then
|
||||
echo "coreapp.toml no longer needs: $dropped. Once the new version works, the Core removes"
|
||||
echo "what they set up for $NAME (its database, sign-in client or mail account)."
|
||||
if [[ " $dropped " == *" postgres "* || " $dropped " == *" mysql "* ]]; then
|
||||
echo "That deletes $NAME's database, with everything in it."
|
||||
read -r -p "Type the app's name ($NAME) to go on: " answer
|
||||
[[ "$answer" == "$NAME" ]] || die "Not deployed; nothing changed."
|
||||
fi
|
||||
fi
|
||||
if grep -qx 'addon=yes' <<< "$plan"; then
|
||||
echo "This Core's tier is '$tier'. Installing records '$NAME' as an add-on app"
|
||||
echo "(ADDON_APPS in /etc/federated), which Federated may bill for."
|
||||
@@ -279,7 +295,7 @@ cmd_deploy() {
|
||||
|
||||
# Install, or update (which recreates the container if the image changed,
|
||||
# even under the same version)
|
||||
installer install $addon $recreate || exit 1
|
||||
installer install $addon $recreate $dropdb || exit 1
|
||||
[[ "$state" == new ]] && echo "(coreapp check tests it at its public address, as people reach it.)"
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user