Development

This commit is contained in:
Matthew Grotke 2026-05-21 03:45:14 -04:00
parent 21db91d512
commit be7ccd3390
4 changed files with 67 additions and 52 deletions

View file

@ -228,7 +228,7 @@ def _set_env_var(content, key, value):
replacement = rf"\g<1>{value}"
new, count = re.subn(pattern, replacement, content, flags=re.MULTILINE)
if count == 0:
# Key not found shouldn't happen with our template, warn and move on
# Key not found; shouldn't happen with our template, warn and move on
print(f" WARNING: could not find {key} in docker-compose.yml")
return new
@ -242,6 +242,21 @@ def setup_docker_compose():
content = COMPOSE_FILE.read_text()
existing_key = re.search(r"^\s*- SECRET_KEY=(.+)$", content, re.MULTILINE)
if existing_key and existing_key.group(1).strip():
print(" Dashboard is already configured.")
if not prompt_yn("Reconfigure? (generates a new SECRET_KEY, invalidates existing sessions)", default="n"):
print()
print(" Starting dashboard container...")
result = subprocess.run(
["docker", "compose", "up", "-d", "--build"],
cwd=COMPOSE_FILE.parent, check=False
)
if result.returncode != 0:
die("docker compose up failed. Check the output above.")
print(" Dashboard container started.")
return
print(" Generating SECRET_KEY...")
secret_key = secrets.token_urlsafe(96) # ~128 chars
@ -363,8 +378,8 @@ def setup_caddy(domain, email):
if CADDYFILE.exists():
existing = CADDYFILE.read_text()
if domain in existing:
print(f" {domain} is already present in {CADDYFILE} — skipping block.")
if f"127.0.0.1:{FLASK_PORT}" in existing:
print(f" Routlin block already present in {CADDYFILE}, skipping.")
else:
CADDYFILE.write_text(existing + block)
print(f" Appended {domain} block to {CADDYFILE}")