Add coreapp core and "What the Core offers" to the skill
coreapp core prints what the Core in the VM offers apps, live: PostgreSQL and which extensions an app can enable itself (the trusted ones; pgvector needs a superuser), MariaDB, Authelia, the mail server, Traefik, Docker and the machine. The skill has the same table with today's versions and says to check the app's requirements against it before choosing a need. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,8 @@ coreapps login <host> <user> keep a token (read from stdin) for
|
||||
installing private apps from host
|
||||
coreapps logout <host> forget host's token
|
||||
coreapps logins the hosts this Core has tokens for
|
||||
coreapps core what this Core offers apps: its services
|
||||
and their versions, and the machine
|
||||
coreapps test-account [--remove] make (or refresh, with the password on
|
||||
stdin) the person coreapp signin signs
|
||||
in with, or remove it
|
||||
@@ -1174,6 +1176,7 @@ def wait_until_answering(m, p):
|
||||
"its log is above).")
|
||||
|
||||
|
||||
|
||||
def update(name, addon_ok):
|
||||
"""An app installed from a repository, to its newest release."""
|
||||
if not re.fullmatch(FIELDS["name"], name) or not is_ours(name):
|
||||
@@ -1244,6 +1247,60 @@ def list_apps():
|
||||
return 0
|
||||
|
||||
|
||||
# --- What this Core offers apps (coreapp core) ---------------------------------------
|
||||
|
||||
def image_tag(container):
|
||||
"""The version in a container's image tag (e.g. 4.39.22), or "?"."""
|
||||
image = run(["docker", "inspect", "-f", "{{.Config.Image}}", container]).stdout.strip()
|
||||
tag = image.rsplit(":", 1)[1] if ":" in image.rsplit("/", 1)[-1] else ""
|
||||
return tag.lstrip("v") or "?"
|
||||
|
||||
|
||||
def core_info():
|
||||
"""The Core's services, versions and machine, as apps see them."""
|
||||
domain, _ = federated_settings()
|
||||
rows = [("Domain", domain)]
|
||||
pg = run(["docker", "exec", "postgresql", "postgres", "--version"]).stdout
|
||||
found = re.search(r"\) ([0-9][0-9.]*)", pg)
|
||||
rows.append(("PostgreSQL", (found.group(1) if found else "?") + ' (needs = ["postgres"])'))
|
||||
ext = run(["docker", "exec", "postgresql", "psql", "-U", "postgres", "-Atc",
|
||||
"SELECT v.trusted, string_agg(e.name || ' ' || e.default_version, ', ' ORDER BY e.name) "
|
||||
"FROM pg_available_extensions e JOIN pg_available_extension_versions v "
|
||||
"ON v.name = e.name AND v.version = e.default_version "
|
||||
"WHERE e.name <> 'plpgsql' GROUP BY v.trusted ORDER BY v.trusted DESC"]).stdout
|
||||
for line in ext.splitlines():
|
||||
trusted, _, names = line.partition("|")
|
||||
rows.append((" extensions the app can enable" if trusted == "t" else
|
||||
" extensions only the Core can enable", names))
|
||||
maria = run(["docker", "exec", "pdnsmysql", "mariadb", "--version"]).stdout
|
||||
found = re.search(r"([0-9][0-9.]*)-MariaDB", maria)
|
||||
rows.append(("MariaDB", (found.group(1) if found else "?") + ' (needs = ["mysql"])'))
|
||||
rows.append(("Authelia", image_tag("authelia") + ' (needs = ["sso"], OpenID Connect)'))
|
||||
rows.append(("Mail server", "docker-mailserver " + image_tag("mail")
|
||||
+ ' (needs = ["email"], sending with SMTP and STARTTLS)'))
|
||||
rows.append(("Traefik", image_tag("traefik") + " (HTTPS and certificates in front of apps)"))
|
||||
docker = run(["docker", "version", "--format", "{{.Server.Version}}"]).stdout.strip()
|
||||
compose = run(["docker", "compose", "version", "--short"]).stdout.strip()
|
||||
rows.append(("Docker", f"{docker or '?'}, Compose {compose or '?'} (one container per app)"))
|
||||
arch = os.uname().machine
|
||||
mem = 0
|
||||
with open("/proc/meminfo") as f:
|
||||
for line in f:
|
||||
if line.startswith("MemTotal:"):
|
||||
mem = int(line.split()[1]) / 1024 / 1024
|
||||
disk = shutil.disk_usage(APPS)
|
||||
fstype = run(["findmnt", "-no", "FSTYPE", "--target", APPS]).stdout.strip()
|
||||
rows.append(("Machine", f"{arch} ({'amd64' if arch == 'x86_64' else arch} images), "
|
||||
f"{os.cpu_count()} CPUs, {mem:.1f} GB memory"))
|
||||
rows.append(("Apps' disk", f"{disk.free / 1e9:.0f} GB free of {disk.total / 1e9:.0f} GB, "
|
||||
f"{fstype or '?'} (/data)"))
|
||||
rows.append(("Not offered", "Redis or other services, a second container, extra host names, "
|
||||
"public ports other than HTTPS, the Core's AI model"))
|
||||
for label, value in rows:
|
||||
print(f"{label + ':':<38} {value}")
|
||||
return 0
|
||||
|
||||
|
||||
# --- The test account (coreapp signin) ---------------------------------------------
|
||||
|
||||
# A person in the Core's LDAP that coreapp signin signs in with, on a
|
||||
@@ -1372,6 +1429,8 @@ def main(args):
|
||||
return list_logins()
|
||||
if cmd == "list" and not rest:
|
||||
return list_apps()
|
||||
if cmd == "core" and not rest:
|
||||
return core_info()
|
||||
if cmd == "test-account" and rest in ([], ["--remove"]):
|
||||
return test_account(remove=bool(rest))
|
||||
sys.stderr.write(__doc__.split("\n\n", 2)[2].strip() + "\n")
|
||||
|
||||
Reference in New Issue
Block a user