LibrePortal/scripts/cli/commands/instance/cli_instance_header.sh
librelad e25c69e2a1 Make multi-instance work without a domain
An instance's isolation never needed a domain — its own slug, dir, secrets,
IP and randomly-allocated host port already make two copies independent. But
the routing layer assumed one, so a LAN-only box got a broken instance rather
than a port-served one. Four fixes:

- instanceCreate now rewrites the parent-service column of the cloned config's
  PORT_ rows to match the service names it stamps into the compose. That value
  is stored as network_resources.parent_service and joined against the
  compose-derived service names, so an instance left carrying the TYPE's
  service name matched nothing: it rendered in the WebUI with no port, no URL
  and no login row despite being up and reachable.

- `instance create --local` (plus a LAN-only toggle in the modal) forces every
  port to access=private, traefik=false, for a second copy that should stay
  off the domain even when one is configured.

- initializeAppVariables forces the traefik column false when no CFG_DOMAIN_n
  is set. Previously a traefik=true port with an empty domain stamped
  Host(`app.`) — a trailing-dot host matching nothing — and dragged APP_URL to
  https://app. with it, breaking every app that builds its links from APP_URL.
  host_setup is blanked for the same reason. The published host port is
  untouched; access type, not the traefik flag, gates allocation.

- APP_URL's direct host-port branch now prefers a new $local_ip_v4 (the source
  IP for the default route) over $public_ip_v4, which is the WAN address from
  an external resolver. LibrePortal never forwards ports, so the WAN address
  was unreachable for exactly the LAN/VPN clients that branch serves.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 02:53:43 +01:00

29 lines
1.6 KiB
Bash

#!/bin/bash
# Instance Commands Header
# Shows available instance commands and help information
cliShowInstanceHelp()
{
echo ""
echo "Available Instance Commands (* is required):"
echo ""
echo " Run more than one copy of a multi-instance-capable app (e.g. two"
echo " Bookstack/WordPress sites). Each instance is a full, isolated app:"
echo " its own data, DB, subdomain, backups and update cadence. Only apps"
echo " with CFG_<TYPE>_MULTI_INSTANCE=true can be instanced."
echo ""
echo " libreportal instance create [type*] [name*] [domain#] [subdomain] [--local]"
echo " - Provision + install a new instance."
echo " type = base app slug (e.g. bookstack)"
echo " name - instance name (e.g. blog)"
echo " domain# - which CFG_DOMAIN_n to route on (default 1)"
echo " subdomain- host label (default <type>-<name>)"
echo " --local - LAN only: no Traefik router, served"
echo " on its own port. Implied when no"
echo " CFG_DOMAIN_n is configured."
echo " libreportal instance remove [slug*] - Uninstall + remove an instance (e.g. bookstack_blog)"
echo " libreportal instance list [type] - List instances (all, or just for one app type)"
echo ""
}