Install Pipelines natively by default on macOS and Linux
Add scripts/setup-native.py and make ./install (and --native) build the server, the CLI and ntfy from source into ~/.local/share/pipelines, detect an existing host OpenCode and Pi instead of installing them, install the packaged authoring skill, migrate an existing Docker database and ntfy auth store, save the host client default and start both services. ./install --docker keeps the previous Docker server + ntfy installation unchanged. ntfy is compiled from its pinned Go module on every host because upstream publishes no macOS server binary (its darwin asset is built with -tags noserver); its cgo SQLite driver is why a C compiler is now required natively. The ntfy credential bootstrap and the client default writer are shared by both installers, installation.Load resolves symlinked prefixes, the Docker migration copies the SQLite write-ahead log so the newest definitions and runs are not lost, and the account subcommands read the generated configuration through NTFY_CONFIG_FILE. Verified on macOS: 115 Python tests, go build/vet/test, and scratch installs that migrate 9 pipelines and 31 runs, build ntfy v2.30.0 and start both services healthy on spare ports before stopping them.
This commit is contained in:
+8
-36
@@ -105,21 +105,13 @@ class Setup:
|
||||
print("Use this address on your phone on the same trusted LAN; do not forward this HTTP port to the Internet.")
|
||||
|
||||
def bootstrap_ntfy(self):
|
||||
token = self.directory / "secrets/ntfy-token.txt"
|
||||
if token.is_symlink():
|
||||
raise ValueError("Refusing a symlink for the publishing token")
|
||||
if token.exists() and token.stat().st_size:
|
||||
print("Keeping existing ntfy publishing token.")
|
||||
else:
|
||||
print("Set a password for ntfy's pipeline-publisher account (not a model-provider account).")
|
||||
self.compose("exec", "ntfy", "ntfy", "user", "add", "--ignore-exists", "pipeline-publisher")
|
||||
self.compose("exec", "-T", "ntfy", "ntfy", "access", "pipeline-publisher", "pipelines", "write-only")
|
||||
result = self.compose("exec", "-T", "ntfy", "ntfy", "token", "add", "pipeline-publisher", capture=True)
|
||||
tokens.save_token(result.stdout + result.stderr, self.directory)
|
||||
# --ignore-exists preserves the phone account's password on re-install.
|
||||
print("Set the phone-reader password if this is a new ntfy account; existing accounts are preserved.")
|
||||
self.compose("exec", "ntfy", "ntfy", "user", "add", "--ignore-exists", "phone-reader")
|
||||
self.compose("exec", "-T", "ntfy", "ntfy", "access", "phone-reader", "pipelines", "read-only")
|
||||
def run_ntfy(args, capture=False, interactive=False):
|
||||
# -T is required for the non-interactive calls; the interactive
|
||||
# `user add` password prompts need the allocated TTY.
|
||||
exec_args = ["exec"] + ([] if interactive else ["-T"]) + ["ntfy", "ntfy", *args]
|
||||
return self.compose(*exec_args, capture=capture)
|
||||
|
||||
tokens.bootstrap_accounts(run_ntfy, self.directory / "secrets/ntfy-token.txt", 0o444)
|
||||
|
||||
def authenticate(self, relogin=False):
|
||||
def connected():
|
||||
@@ -554,27 +546,7 @@ printf 'header = "Authorization: Bearer %s"\\n' "$(cat "$PIPELINES_NTFY_TOKEN_FI
|
||||
print("Verified: host client reaches the ntfy-enabled Docker server at " + endpoint)
|
||||
|
||||
def configure_client(self, endpoint):
|
||||
root = Path(os.environ.get("XDG_CONFIG_HOME") or Path.home()/".config")
|
||||
directory = root/"pipelines"
|
||||
path = directory/"client.json"
|
||||
if path.is_symlink():
|
||||
raise ValueError("Refusing to modify symlinked client.json; use the printed --url explicitly")
|
||||
existing = json.loads(path.read_text()) if path.exists() else {}
|
||||
if not isinstance(existing, dict):
|
||||
raise ValueError("client.json must contain an object; existing configuration was not replaced")
|
||||
existing["server_url"] = endpoint
|
||||
directory.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
temporary = None
|
||||
try:
|
||||
with tempfile.NamedTemporaryFile(mode="w", dir=directory, delete=False) as file:
|
||||
temporary = Path(file.name)
|
||||
os.chmod(temporary, 0o600)
|
||||
json.dump(existing, file, indent=2)
|
||||
file.write("\n")
|
||||
os.replace(temporary, path)
|
||||
finally:
|
||||
if temporary is not None:
|
||||
temporary.unlink(missing_ok=True)
|
||||
path = configure.configure_client(endpoint)
|
||||
print(f"Saved Docker client default: {endpoint} ({path}). Restart the TUI.")
|
||||
override = os.environ.get("PIPELINES_URL", "")
|
||||
if override and override != endpoint:
|
||||
|
||||
Reference in New Issue
Block a user