Development
This commit is contained in:
parent
abf05a60fb
commit
831bc88a92
4 changed files with 24 additions and 10 deletions
|
|
@ -2,7 +2,7 @@ import json, subprocess, hashlib, os, uuid
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from flask import session
|
from flask import session
|
||||||
|
|
||||||
CONFIGS_DIR = '/configs'
|
CONFIGS_DIR = '/routlin_location'
|
||||||
CORE_FILE = f'{CONFIGS_DIR}/core.json'
|
CORE_FILE = f'{CONFIGS_DIR}/core.json'
|
||||||
DASHBOARD_QUEUE = f'{CONFIGS_DIR}/.dashboard-queue'
|
DASHBOARD_QUEUE = f'{CONFIGS_DIR}/.dashboard-queue'
|
||||||
DASHBOARD_DONE = f'{CONFIGS_DIR}/.dashboard-done'
|
DASHBOARD_DONE = f'{CONFIGS_DIR}/.dashboard-done'
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ from config_utils import core_hash, get_pending_entries, get_dashboard_pending,
|
||||||
bp = Blueprint('view_page', __name__)
|
bp = Blueprint('view_page', __name__)
|
||||||
|
|
||||||
DATA_DIR = '/data'
|
DATA_DIR = '/data'
|
||||||
CONFIGS_DIR = '/configs'
|
CONFIGS_DIR = '/routlin_location'
|
||||||
|
|
||||||
LEVEL_RANK = {'nothing': 0, 'viewer': 1, 'administrator': 2, 'manager': 3}
|
LEVEL_RANK = {'nothing': 0, 'viewer': 1, 'administrator': 2, 'manager': 3}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@ services:
|
||||||
- "25327:25327"
|
- "25327:25327"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/data
|
- ./data:/data
|
||||||
- $HOME/routlin:/configs
|
- $HOME/routlin:/routlin_location
|
||||||
- $HOME/routlin/validation.py:/app/validation.py
|
|
||||||
- /sys/class/net:/sys/class/net:ro
|
- /sys/class/net:/sys/class/net:ro
|
||||||
- /sys/devices:/sys/devices:ro
|
- /sys/devices:/sys/devices:ro
|
||||||
environment:
|
environment:
|
||||||
|
- PYTHONPATH=/routlin_location
|
||||||
- PRODUCT_DISPLAY_NAME=Routlin Dashboard
|
- PRODUCT_DISPLAY_NAME=Routlin Dashboard
|
||||||
- INITIAL_MANAGER_EMAIL=mgrotke@gmail.com
|
- INITIAL_MANAGER_EMAIL=mgrotke@gmail.com
|
||||||
- SECRET_KEY=ey8hSQCCYE5kQXV8nOg1CB44LSd3AoUet2ZBc3aZlFrwBbazE7aHcxXWyuT97eAObet5jmOL0CjMg0rB1hE4d2SBVYHPfl8De55EiFv307r1QP3Mf5XgOSSCxD3TuD
|
- SECRET_KEY=ey8hSQCCYE5kQXV8nOg1CB44LSd3AoUet2ZBc3aZlFrwBbazE7aHcxXWyuT97eAObet5jmOL0CjMg0rB1hE4d2SBVYHPfl8De55EiFv307r1QP3Mf5XgOSSCxD3TuD
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,19 @@ def die(msg):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def _compose_env():
|
||||||
|
"""Return an env dict with HOME set to the invoking user's home, not root's."""
|
||||||
|
import pwd
|
||||||
|
sudo_user = os.environ.get('SUDO_USER')
|
||||||
|
if sudo_user:
|
||||||
|
try:
|
||||||
|
home = pwd.getpwnam(sudo_user).pw_dir
|
||||||
|
return {**os.environ, 'HOME': home}
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
return os.environ.copy()
|
||||||
|
|
||||||
|
|
||||||
def check_root():
|
def check_root():
|
||||||
if os.geteuid() != 0:
|
if os.geteuid() != 0:
|
||||||
die("This script must be run as root (sudo python3 install.py).")
|
die("This script must be run as root (sudo python3 install.py).")
|
||||||
|
|
@ -250,19 +263,20 @@ def setup_docker_compose(reuse_config=False):
|
||||||
if reuse_config:
|
if reuse_config:
|
||||||
import time
|
import time
|
||||||
cache_bust = str(int(time.time()))
|
cache_bust = str(int(time.time()))
|
||||||
|
env = _compose_env()
|
||||||
print("\n Stopping existing container...")
|
print("\n Stopping existing container...")
|
||||||
subprocess.run(["docker", "compose", "down"], cwd=COMPOSE_FILE.parent, check=False)
|
subprocess.run(["docker", "compose", "down"], cwd=COMPOSE_FILE.parent, env=env, check=False)
|
||||||
print("\n Building dashboard image...")
|
print("\n Building dashboard image...")
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["docker", "compose", "build", "--build-arg", f"CACHE_BUST={cache_bust}"],
|
["docker", "compose", "build", "--build-arg", f"CACHE_BUST={cache_bust}"],
|
||||||
cwd=COMPOSE_FILE.parent, check=False
|
cwd=COMPOSE_FILE.parent, env=env, check=False
|
||||||
)
|
)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
die("docker compose build failed. Check the output above.")
|
die("docker compose build failed. Check the output above.")
|
||||||
print("\n Starting dashboard container...")
|
print("\n Starting dashboard container...")
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["docker", "compose", "up", "-d"],
|
["docker", "compose", "up", "-d"],
|
||||||
cwd=COMPOSE_FILE.parent, check=False
|
cwd=COMPOSE_FILE.parent, env=env, check=False
|
||||||
)
|
)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
die("docker compose up failed. Check the output above.")
|
die("docker compose up failed. Check the output above.")
|
||||||
|
|
@ -301,14 +315,14 @@ def setup_docker_compose(reuse_config=False):
|
||||||
COMPOSE_FILE.write_text(content)
|
COMPOSE_FILE.write_text(content)
|
||||||
print(f"\n Written: {COMPOSE_FILE}")
|
print(f"\n Written: {COMPOSE_FILE}")
|
||||||
|
|
||||||
|
env = _compose_env()
|
||||||
print("\n Stopping existing container...")
|
print("\n Stopping existing container...")
|
||||||
subprocess.run(["docker", "compose", "down"], cwd=COMPOSE_FILE.parent, check=False)
|
subprocess.run(["docker", "compose", "down"], cwd=COMPOSE_FILE.parent, env=env, check=False)
|
||||||
|
|
||||||
print("\n Starting dashboard container...")
|
print("\n Starting dashboard container...")
|
||||||
compose_dir = COMPOSE_FILE.parent
|
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["docker", "compose", "up", "-d", "--build"],
|
["docker", "compose", "up", "-d", "--build"],
|
||||||
cwd=compose_dir, check=False
|
cwd=COMPOSE_FILE.parent, env=env, check=False
|
||||||
)
|
)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
die("docker compose up failed. Check the output above.")
|
die("docker compose up failed. Check the output above.")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue