Bind both Docker services to 0.0.0.0 by default
This commit is contained in:
+17
-4
@@ -2,6 +2,7 @@
|
||||
"""Configure, authenticate and verify the full Docker installation."""
|
||||
import argparse
|
||||
import importlib.util
|
||||
import ipaddress
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
@@ -35,14 +36,26 @@ class Setup:
|
||||
|
||||
def settings(self, args):
|
||||
settings = self.directory / ".env"
|
||||
bind = str(ipaddress.IPv4Address(args.bind_address or "0.0.0.0"))
|
||||
if settings.is_symlink():
|
||||
raise ValueError("Refusing to modify a symlinked .env")
|
||||
if settings.exists():
|
||||
if any((args.ntfy_url, args.bind_address, args.timezone, args.port)):
|
||||
if any((args.ntfy_url, args.timezone, args.port)):
|
||||
raise ValueError(".env already exists; edit it explicitly rather than replace existing configuration")
|
||||
print("Keeping existing .env and credentials.")
|
||||
text = settings.read_text()
|
||||
for key, value in (("NTFY_BIND_ADDRESS", bind),
|
||||
("PIPELINES_BIND_ADDRESS", "0.0.0.0")):
|
||||
if any(line.startswith(key + "=") for line in text.splitlines()):
|
||||
text = "".join(key + "=" + value + "\n" if line.startswith(key + "=") else line
|
||||
for line in text.splitlines(keepends=True))
|
||||
else:
|
||||
text = text.rstrip("\n") + "\n" + key + "=" + value + "\n"
|
||||
if text != settings.read_text():
|
||||
settings.write_text(text)
|
||||
print(f"Docker binds: ntfy {bind}, Pipelines 0.0.0.0; existing URLs, timezone, ports and credentials retained.")
|
||||
return
|
||||
address = lan.detect_lan() if not args.ntfy_url else None
|
||||
url = args.ntfy_url or f"http://{address}:8090"
|
||||
bind = args.bind_address or address or "127.0.0.1"
|
||||
timezone = args.timezone
|
||||
if not timezone:
|
||||
try:
|
||||
@@ -132,7 +145,7 @@ printf 'header = "Authorization: Bearer %s"\\n' "$(cat "$PIPELINES_NTFY_TOKEN_FI
|
||||
def arguments(argv=None):
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--ntfy-url", help="Override the auto-detected LAN ntfy address")
|
||||
parser.add_argument("--bind-address", help="Override the detected LAN bind IP")
|
||||
parser.add_argument("--bind-address", help="Override ntfy's default 0.0.0.0 bind address")
|
||||
parser.add_argument("--timezone", help="Override the detected timezone (fallback: UTC)")
|
||||
parser.add_argument("--port", type=int)
|
||||
parser.add_argument("--relogin", action="store_true", help="open OpenCode provider login again without deleting accounts")
|
||||
|
||||
Reference in New Issue
Block a user