diff --git a/vps/owrt-remote-hub.py b/vps/owrt-remote-hub.py index a4800f0..324de1f 100644 --- a/vps/owrt-remote-hub.py +++ b/vps/owrt-remote-hub.py @@ -33,6 +33,7 @@ except Exception: APP_NAME = "OpenWrt Remote Hub" +RAW_REPO_BASE = "https://raw.githubusercontent.com/kzolotarev95/luci-app-owrt-remote/main" STATE_DIR = Path(os.environ.get("OWRT_REMOTE_STATE_DIR", "/var/lib/owrt-remote")) DB_PATH = Path(os.environ.get("OWRT_REMOTE_DB", str(STATE_DIR / "hub.db"))) AUTH_FILE = STATE_DIR / "hub-auth.json" @@ -1520,6 +1521,82 @@ def vps_terminal_row(): return {"id": VPS_TERMINAL_ID, "name": "VPS"} +def vps_terminal_commands(host): + host = (host or "").strip() or "YOUR_VPS_IP" + return [ + { + "title": "Обновить Hub", + "note": "Свежий hub.py из main + restart сервиса", + "command": f'v=$(date +%s); curl -fsSL -o /opt/owrt-remote/owrt-remote-hub.py "{RAW_REPO_BASE}/vps/owrt-remote-hub.py?v=$v" && chmod +x /opt/owrt-remote/owrt-remote-hub.py && systemctl restart owrt-remote && systemctl status owrt-remote --no-pager -l', + }, + { + "title": "Статус Hub", + "note": "Проверка сервиса owrt-remote", + "command": "systemctl status owrt-remote --no-pager -l", + }, + { + "title": "Логи Hub", + "note": "Последние строки journald по Hub", + "command": "journalctl -u owrt-remote -n 80 --no-pager -l", + }, + { + "title": "Проверка портов", + "note": "Слушают ли 80/443/8088/8443", + "command": "ss -lntp | grep -E ':(80|443|8088|8443)'", + }, + { + "title": "Health Hub", + "note": "Локальная health-проверка Hub", + "command": "curl -sS http://127.0.0.1:8088/health", + }, + { + "title": "Включить HTTPS", + "note": "Обновить https-конфиг из репо для текущего host", + "command": f'curl -fsSL "{RAW_REPO_BASE}/vps/enable-https.sh?v=$(date +%s)" | sh -s -- {host}', + }, + { + "title": "Установить VPS заново", + "note": "install-vps.sh из репо", + "command": f'curl -fsSL "{RAW_REPO_BASE}/vps/install-vps.sh?v=$(date +%s)" | sh', + }, + ] + + +def vps_quick_commands_html(host): + cards = [] + for item in vps_terminal_commands(host): + title = html.escape(item["title"]) + note = html.escape(item["note"]) + command = item["command"] + safe_cmd = html.escape(command, quote=True) + preview = html.escape(command) + cards.append( + f""" + + + {title} + {note} + + {preview} + + Копировать + В терминал + + """.strip() + ) + joined = "\n".join(cards) + return f""" + + + Быстрые команды + Команды взяты из репозитория luci-app-owrt-remote. Можно копировать или сразу отправлять в VPS terminal. + + +{joined} + + """.strip() + + def ssh_ws_token(secret, router_id): return hmac.new( secret.encode("utf-8"), @@ -2533,6 +2610,7 @@ body{{min-height:100vh;margin:0;background-color:var(--bg);background-image:radi Назад в Hub +__QUICK_COMMANDS_HTML__ Terminal @@ -2964,7 +3042,7 @@ window.setTimeout(focusTerminal, 80);
{preview}
Команды взяты из репозитория luci-app-owrt-remote. Можно копировать или сразу отправлять в VPS terminal.