Install apps from their repository, including private ones

coreapps plan|install <https://host/owner/repo>[@tag] reads only
coreapp.toml and icon.png at the tag's commit (depth 1, blobs on demand,
regular files only), with git limited to https and no prompts or system
settings. The default tag is the newest numeric release; version must
match the tag; the image is always pulled. The marker records source,
tag and commit; the same name from another repository is refused.
coreapps update <name> moves to the newest release. On the workstation:
coreapp install <url> (shows the app and its needs, asks) and update.

Private apps: coreapps login <host> <user> keeps a read-only token (from
stdin) in /etc/coreapps/credentials (root only), checked with the host's
registry first. git gets it as an extraHeader for that host only, docker
in a config made for each pull. coreapp login/logout/logins on the
workstation. Tested with a private repository and package on Federated's
Gitea.

Fixed: old images of docker.io/library/... weren't deleted (docker lists
them by short name); remove force-deleted images another app could use;
coreapp help cut off multi-line descriptions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 14:51:41 -07:00
co-authored by Claude Opus 5.5
parent ed2841f092
commit bef3b86970
6 changed files with 608 additions and 37 deletions
+90 -3
View File
@@ -15,12 +15,20 @@
# coreapp shell [command] a shell in its container, or run one command there
# coreapp remove uninstall it from the Core (asks first)
# coreapp list the apps on the Core installed this way
# coreapp install <https://host/owner/repo>[@tag]
# install a published app from its repository, as
# a Core's owner would (shows what it needs first)
# coreapp update <name> update an app installed from a repository to its
# newest release
# coreapp login <host> give the Core a token for private apps from host
# (asks for the user and token); logout <host>,
# logins: forget one, list them
# coreapp publish [--platform <list>]
# build the release image and push it to the
# registry in coreapp.toml, and tag the commit
#
# Run everything but `new` and `list` in the app's folder (the one with
# coreapp.toml). COREAPP_VM picks the VM (default coreserver).
# Run deploy, check, status, logs, shell, remove and publish in the app's
# folder (the one with coreapp.toml). COREAPP_VM picks the VM (default coreserver).
set -euo pipefail
@@ -38,7 +46,8 @@ VM="${COREAPP_VM:-coreserver}"
die() { echo "$*" >&2; exit 1; }
usage() {
sed -n '/^# coreapp /s/^# //p' "${BASH_SOURCE[0]}"
# The command list at the top of this file, continuation lines included
sed -n '/^# coreapp new/,/^#$/{/^#$/d;s/^# //p}' "${BASH_SOURCE[0]}"
}
# --- The Core -------------------------------------------------------------
@@ -319,6 +328,79 @@ cmd_list() {
core "$REMOTE_INSTALLER/coreapps list"
}
# --- install, update (published apps) -----------------------------------
cmd_install() {
local source="${1:-}" plan key value answer addon=""
local -A info=()
[[ $# -eq 1 && "$source" == https://* ]] \
|| die "Usage: coreapp install <https://host/owner/repo>[@tag] (default: its newest release)"
init_core
sync_installer
echo "Reading $source..."
plan="$(core "$REMOTE_INSTALLER/coreapps plan $(printf '%q' "$source")")" || exit 1
while IFS='=' read -r key value; do info[$key]="$value"; done <<< "$plan"
echo
echo " ${info[title]} ${info[version]}${info[description]:+: ${info[description]}}"
echo " From: ${info[source]} (${info[tag]}, commit ${info[commit]:0:12})"
echo " Image: ${info[image]}:${info[version]}"
echo " Needs: ${info[needs]:-nothing from the Core}"
if [[ "${info[state]}" == update ]]; then
echo " Updates the installed ${info[name]}, keeping its settings and data."
else
echo " Installs it at ${info[url]}"
fi
echo
if [[ "${info[addon]}" == yes ]]; then
echo "This Core's tier is '${info[tier]}'. Installing records '${info[name]}' as an add-on"
echo "app (ADDON_APPS in /etc/federated), which Federated may bill for."
addon=--addon-ok
fi
read -r -p "Install it? [y/N] " answer
[[ "$answer" =~ ^[Yy] ]] || die "Not installed."
core "$REMOTE_INSTALLER/coreapps install $addon $(printf '%q' "$source")"
}
cmd_update() {
local name="${1:-}"
[[ $# -eq 1 && "$name" =~ ^[a-z][a-z0-9-]*$ ]] || die "Usage: coreapp update <name>"
init_core
sync_installer
core "$REMOTE_INSTALLER/coreapps update $name"
}
cmd_login() {
local host="${1:-}" user token
[[ $# -eq 1 && "$host" =~ ^[a-z0-9][a-z0-9.:-]*$ ]] \
|| die "Usage: coreapp login <host> (e.g. coreapp login gitea.federated.computer)"
echo "The Core in '$VM' keeps this token to install private apps from $host:"
echo "their repositories and images. For Gitea, make a token for it with read"
echo "access to repositories and packages (Settings > Applications)."
read -r -p "User on $host: " user
[[ "$user" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]] || die "'$user' isn't a user name."
read -r -s -p "Token: " token
echo
init_core
sync_installer
# On stdin, so it's never in a command line
printf '%s\n' "$token" | core "$REMOTE_INSTALLER/coreapps login $host $user"
}
cmd_logout() {
local host="${1:-}"
[[ $# -eq 1 && "$host" =~ ^[a-z0-9][a-z0-9.:-]*$ ]] || die "Usage: coreapp logout <host>"
init_core
sync_installer
core "$REMOTE_INSTALLER/coreapps logout $host"
}
cmd_logins() {
init_core
sync_installer
core "$REMOTE_INSTALLER/coreapps logins"
}
# --- publish ----------------------------------------------------------------
# A registry image name from the repository's git remote, as a suggestion:
@@ -425,6 +507,11 @@ case "$cmd" in
remove | rm) cmd_remove ;;
list | ls) cmd_list ;;
publish) cmd_publish "$@" ;;
install) cmd_install "$@" ;;
update) cmd_update "$@" ;;
login) cmd_login "$@" ;;
logout) cmd_logout "$@" ;;
logins) cmd_logins ;;
help | -h | --help) usage ;;
*) usage >&2; exit 1 ;;
esac