From 6e8f4c15ab90ab90b254f2b2415a9eaa43f5d612 Mon Sep 17 00:00:00 2001 From: kzolotarev95 Date: Wed, 1 Jul 2026 23:29:04 +0400 Subject: [PATCH] Prompt for VPS host during install --- README.md | 10 +++++++++- vps/install-vps.sh | 43 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 80d59b1..84cf8fd 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,14 @@ curl -fsSL "https://raw.githubusercontent.com/kzolotarev95/luci-app-owrt-remote/main/vps/install-vps.sh?v=$(date +%s)" | sudo sh ``` +Установщик спросит: + +```text +IP/домен VPS: +``` + +Можно вставить домен, например `hub.example.com`, или нажать Enter, чтобы взять найденный IP сервера. + После установки в конце будет вход: ```text @@ -61,7 +69,7 @@ owrt-remote doctor owrt-remote status ``` -Если нужен домен, передай его установщику: +Если хочешь без вопроса сразу передать домен: ```sh curl -fsSL "https://raw.githubusercontent.com/kzolotarev95/luci-app-owrt-remote/main/vps/install-vps.sh?v=$(date +%s)" | sudo sh -s -- hub.example.com diff --git a/vps/install-vps.sh b/vps/install-vps.sh index e0653f9..b285459 100755 --- a/vps/install-vps.sh +++ b/vps/install-vps.sh @@ -2,7 +2,7 @@ set -u APP_NAME="OpenWrt Remote Hub" -INSTALLER_VERSION="2026-07-01-nginx-https-v5" +INSTALLER_VERSION="2026-07-01-host-prompt-v6" RAW_BASE="${RAW_URL:-https://raw.githubusercontent.com/kzolotarev95/luci-app-owrt-remote/main}" STATE_DIR="${OWRT_REMOTE_STATE_DIR:-/var/lib/owrt-remote}" HUB_LOGIN="${HUB_LOGIN:-admin}" @@ -33,6 +33,37 @@ need_cmd() { command -v "$1" >/dev/null 2>&1 || die "не найдена команда: $1" } +detect_public_vps_host() { + if command -v curl >/dev/null 2>&1; then + host="$(curl -4fsS --max-time 5 https://api.ipify.org 2>/dev/null || true)" + if [ -n "$host" ]; then + printf '%s\n' "$host" + return + fi + fi + hostname -I 2>/dev/null | awk '{print $1}' +} + +prompt_vps_host() { + default_host="$(detect_public_vps_host)" + host="" + + if [ -r /dev/tty ] && [ -w /dev/tty ]; then + printf '\n' >/dev/tty + printf 'IP или домен VPS для панели Hub\n' >/dev/tty + if [ -n "$default_host" ]; then + printf 'Нажми Enter, чтобы взять найденный IP: %s\n' "$default_host" >/dev/tty + fi + printf 'IP/домен VPS: ' >/dev/tty + IFS= read -r host /dev/null 2>&1; then - host="$(curl -4fsS --max-time 5 https://api.ipify.org 2>/dev/null || true)" - if [ -n "$host" ]; then - printf '%s\n' "$host" - return - fi - fi - hostname -I 2>/dev/null | awk '{print $1}' + prompt_vps_host } install_packages() { @@ -215,6 +239,7 @@ main() { need_cmd python3 host="$(detect_vps_host "${1:-}")" [ -n "$host" ] || host="YOUR_VPS_IP" + info "IP/домен VPS: $host" install_xray_binary install_files install_xray_service