diff --git a/app.py b/app.py index 26a6937..fb237a1 100644 --- a/app.py +++ b/app.py @@ -686,12 +686,45 @@ def settings_page():

Установка на роутер

Keenetic/Netcraze с Entware — выполнить по SSH на роутере:

- curl -s http://{SERVER_IP}/init/TOKEN.sh | sh + {_render_install_commands()}
""" return render(html) +TOKENS_FILE = f"{PHOBOS_DIR}/tokens/tokens.json" + + +def _render_install_commands(): + """Read tokens and render install commands for each client.""" + try: + if os.path.exists(TOKENS_FILE): + with open(TOKENS_FILE) as f: + tokens = json.load(f) + else: + tokens = [] + except Exception: + tokens = [] + + if not tokens: + return '

Нет активных токенов. Добавьте клиента.

' + + lines = "" + for t in tokens: + client = t.get("client", "?") + token = t.get("token", "") + expires = t.get("expires", 0) + exp_str = datetime.fromtimestamp(expires).strftime("%Y-%m-%d %H:%M") if expires else "?" + cmd = f"wget -O - http://{SERVER_IP}/init/{token}.sh | sh" + lines += f""" +
+ {client} + (до {exp_str}) + {cmd} +
""" + return lines + + def _load_server_env(): """Load server.env as dict for subprocess env.""" env = {}