Route native service commands and configure fresh authoring role
Select native installs only via explicit PIPELINES_PREFIX or the matching owned prefix/bin/pipelines executable. Route enable/status/disable to the existing native supervisor; validate registration ownership, label and command, keep preview read-only, and disable login registration before stopping. Never fall back to a standalone service for an invalid explicit prefix. Fresh native installs explicitly enable authoring, while reinstalls preserve false or missing legacy role settings. Add explicit --allow-authoring/--no-authoring overrides and pass the server flag only for manifest true. Print a copyable native enable command and update installation help/docs. No Docker configuration changes. Checks: 54 mocked native installer/lifecycle tests; 8 entrypoint tests; offline Go installation/CLI tests and vet; gofmt clean; shell syntax and diff checks. No live install, restart, deployment, permission/config changes, or native Linux verification.
This commit is contained in:
@@ -19,6 +19,7 @@ import os
|
||||
import platform
|
||||
import plistlib
|
||||
import secrets
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -227,6 +228,20 @@ class Setup:
|
||||
raw = self.prefix_argument or self.environ.get("PIPELINES_PREFIX") or default
|
||||
return Path(raw).expanduser().resolve()
|
||||
|
||||
def authoring_role(self, prefix, requested):
|
||||
"""Fresh single-user installs author; never widen an existing server's role."""
|
||||
if requested is not None:
|
||||
return requested
|
||||
path = prefix / MARKER
|
||||
if not path.exists() and not path.is_symlink():
|
||||
return True
|
||||
if path.is_symlink() or not path.is_file():
|
||||
raise ValueError("Refusing to read authoring role from a non-regular installation manifest")
|
||||
existing = json.loads(path.read_text())
|
||||
if not isinstance(existing, dict) or not isinstance(existing.get("allow_authoring", False), bool):
|
||||
raise ValueError("Invalid existing authoring role; no permission changes were made")
|
||||
return existing.get("allow_authoring", False)
|
||||
|
||||
# --- prefix layout ---------------------------------------------------
|
||||
|
||||
def prepare_layout(self, prefix):
|
||||
@@ -581,6 +596,7 @@ class Setup:
|
||||
except ValueError:
|
||||
raise ValueError("Invalid API/web bind address; use an IPv4 address such as 0.0.0.0 or 127.0.0.1") from None
|
||||
prefix = self.resolve_prefix()
|
||||
allow_authoring = self.authoring_role(prefix, args.allow_authoring)
|
||||
harness = self.harness()
|
||||
service_path = self.service_path()
|
||||
# Reuse an already built ntfy binary and skip the release lookup, so a
|
||||
@@ -625,6 +641,7 @@ class Setup:
|
||||
path_value = str(prefix / "bin") + os.pathsep + self.environ.get("PATH", "")
|
||||
manifest = {
|
||||
"format": 1,
|
||||
"allow_authoring": allow_authoring,
|
||||
"prefix": str(prefix),
|
||||
"python": python,
|
||||
"server_port": args.port,
|
||||
@@ -673,6 +690,10 @@ class Setup:
|
||||
print(f"ntfy is configured for {base_url}; server, web proxy and ntfy have login autostart ({service_path}).")
|
||||
print(f"Web: http://{lan_ip if args.web_host == '0.0.0.0' else args.web_host}:{args.web_port}/ "
|
||||
f"(sign-in password in {web['auth_file']}; existing credentials retained).")
|
||||
print("Login autostart is already enabled. To enable/start it again, run:\n "
|
||||
+ shlex.join([str(prefix / "bin/pipelines"), "service", "enable"]))
|
||||
print("Configured server role: " + ("single-user authoring enabled (web pipeline creation/publication allowed)."
|
||||
if allow_authoring else "execution-only (pipeline publication disabled)."))
|
||||
if args.bind_address == "0.0.0.0":
|
||||
print(f"Phone client server URL: ws://{lan_ip}:{args.port}/connect "
|
||||
"(use a workspace path that exists on this server).")
|
||||
@@ -692,6 +713,11 @@ def arguments(argv=None):
|
||||
help="Unauthenticated server bind address (default 127.0.0.1; expose only the web proxy)")
|
||||
parser.add_argument("--ntfy-port", type=int, default=DEFAULT_NTFY_PORT, help="ntfy listen port")
|
||||
parser.add_argument("--model", help="Record an explicit default model; otherwise host OpenCode configuration is reused")
|
||||
role = parser.add_mutually_exclusive_group()
|
||||
role.add_argument("--allow-authoring", dest="allow_authoring", action="store_true", default=None,
|
||||
help="Explicitly enable pipeline publication; fresh native installs default to enabled")
|
||||
role.add_argument("--no-authoring", dest="allow_authoring", action="store_false",
|
||||
help="Execution-only server; disable pipeline publication (reinstalls otherwise preserve the recorded role)")
|
||||
parser.add_argument("--replace-data", action="store_true",
|
||||
help="Allow Docker migration to replace an existing native database/auth store")
|
||||
return parser.parse_args(argv)
|
||||
|
||||
Reference in New Issue
Block a user