Development
This commit is contained in:
parent
e4b2ab68e4
commit
4165a30d57
1 changed files with 33 additions and 18 deletions
|
|
@ -235,21 +235,22 @@ def _set_env_var(content, key, value):
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
|
||||||
def setup_docker_compose():
|
def _dash_already_configured():
|
||||||
|
if not COMPOSE_FILE.exists():
|
||||||
|
return False
|
||||||
|
return bool(re.search(r"^\s*- SECRET_KEY=\S", COMPOSE_FILE.read_text(), re.MULTILINE))
|
||||||
|
|
||||||
|
def setup_docker_compose(reuse_config=False):
|
||||||
header("Dashboard Configuration")
|
header("Dashboard Configuration")
|
||||||
|
|
||||||
if not COMPOSE_FILE.exists():
|
if not COMPOSE_FILE.exists():
|
||||||
die(f"docker-compose.yml not found at {COMPOSE_FILE}\n"
|
die(f"docker-compose.yml not found at {COMPOSE_FILE}\n"
|
||||||
f" Ensure the routlin-dash directory is at {COMPOSE_FILE.parent}")
|
f" Ensure the routlin-dash directory is at {COMPOSE_FILE.parent}")
|
||||||
|
|
||||||
content = COMPOSE_FILE.read_text()
|
if reuse_config:
|
||||||
|
print("\n Stopping existing container...")
|
||||||
existing_key = re.search(r"^\s*- SECRET_KEY=(.+)$", content, re.MULTILINE)
|
subprocess.run(["docker", "compose", "down"], cwd=COMPOSE_FILE.parent, check=False)
|
||||||
if existing_key and existing_key.group(1).strip():
|
print("\n Starting dashboard container...")
|
||||||
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(
|
result = subprocess.run(
|
||||||
["docker", "compose", "up", "-d", "--build"],
|
["docker", "compose", "up", "-d", "--build"],
|
||||||
cwd=COMPOSE_FILE.parent, check=False
|
cwd=COMPOSE_FILE.parent, check=False
|
||||||
|
|
@ -259,6 +260,8 @@ def setup_docker_compose():
|
||||||
print(" Dashboard container started.")
|
print(" Dashboard container started.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
content = COMPOSE_FILE.read_text()
|
||||||
|
|
||||||
print(" Generating SECRET_KEY...")
|
print(" Generating SECRET_KEY...")
|
||||||
secret_key = secrets.token_urlsafe(96) # ~128 chars
|
secret_key = secrets.token_urlsafe(96) # ~128 chars
|
||||||
|
|
||||||
|
|
@ -455,6 +458,11 @@ def main():
|
||||||
print(" be edited manually.")
|
print(" be edited manually.")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
dash_installed = _dash_already_configured()
|
||||||
|
if dash_installed:
|
||||||
|
print(" Web dashboard is already installed.")
|
||||||
|
want_dashboard = prompt_yn("Rebuild?", default="n")
|
||||||
|
else:
|
||||||
want_dashboard = prompt_yn("Install the web dashboard?", default="y")
|
want_dashboard = prompt_yn("Install the web dashboard?", default="y")
|
||||||
|
|
||||||
if not want_dashboard:
|
if not want_dashboard:
|
||||||
|
|
@ -466,6 +474,13 @@ def main():
|
||||||
print("Done.")
|
print("Done.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
reuse_config = False
|
||||||
|
if dash_installed:
|
||||||
|
reuse_config = prompt_yn(
|
||||||
|
"Re-use existing configuration? (Keeps SECRET_KEY and SMTP credentials, preserving active sessions and email settings)",
|
||||||
|
default="y"
|
||||||
|
)
|
||||||
|
|
||||||
# -- Docker ----------------------------------------------------
|
# -- Docker ----------------------------------------------------
|
||||||
header("Docker")
|
header("Docker")
|
||||||
if pm_ok:
|
if pm_ok:
|
||||||
|
|
@ -476,7 +491,7 @@ def main():
|
||||||
print(" Docker is already installed.")
|
print(" Docker is already installed.")
|
||||||
|
|
||||||
# -- docker-compose.yml ----------------------------------------
|
# -- docker-compose.yml ----------------------------------------
|
||||||
setup_docker_compose()
|
setup_docker_compose(reuse_config=reuse_config)
|
||||||
create_dotfiles()
|
create_dotfiles()
|
||||||
|
|
||||||
# -- External access -------------------------------------------
|
# -- External access -------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue