From 6d7c59b17c60f63328b2a72d11b31c56773dd65c Mon Sep 17 00:00:00 2001 From: kzolotarev95 Date: Mon, 29 Jun 2026 05:35:35 +0400 Subject: [PATCH] Add OpenWrt Xray tmp installer --- README.md | 22 +++++--------- files/usr/sbin/owrt-remote | 57 ++++++++++++++++++++++++++++++++++- files/www/cgi-bin/owrt-remote | 14 +++++++-- install.sh | 1 + 4 files changed, 76 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 5f09818..01e3518 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,8 @@ owrt-remote heartbeat ## Xray на OpenWrt +OpenWrt Remote не кладет Xray автоматически в прошивку: бинарник большой, и на многих роутерах не хватает flash. Если в проверке видно `нет Xray: /usr/bin/xray`, поставь его одним из способов ниже. + Если хватает flash-памяти: ```sh @@ -183,26 +185,16 @@ opkg update opkg install xray-core ``` -Если flash мало, можно запустить Xray из RAM для теста: +Если flash мало, можно запустить Xray из RAM: ```sh -mkdir -p /var/lock /var/run /tmp/owrt-xray -cd /tmp/owrt-xray -wget -O xray.zip "https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-arm64-v8a.zip" -command -v unzip >/dev/null 2>&1 || { opkg update; opkg install unzip; } -unzip -o xray.zip xray -chmod +x /tmp/owrt-xray/xray -/tmp/owrt-xray/xray version -uci set owrtremote.main.xray_bin='/tmp/owrt-xray/xray' -uci commit owrtremote +owrt-remote install-xray-tmp +owrt-remote render-client /etc/init.d/owrt-remote restart +owrt-remote doctor ``` -Для другой архитектуры скачай подходящий архив Xray: - -```text -https://github.com/XTLS/Xray-core/releases/latest -``` +То же самое можно сделать кнопкой `Поставить Xray в /tmp` в локальной панели роутера. ## Обновление diff --git a/files/usr/sbin/owrt-remote b/files/usr/sbin/owrt-remote index 59ed2f0..be6b4e8 100644 --- a/files/usr/sbin/owrt-remote +++ b/files/usr/sbin/owrt-remote @@ -17,6 +17,7 @@ usage() { Использование: owrt-remote status owrt-remote doctor + owrt-remote install-xray-tmp owrt-remote render-client [--stdout] owrt-remote run owrt-remote heartbeat @@ -145,7 +146,7 @@ xray_bin_path() { printf '%s' "$configured" return fi - for candidate in /usr/bin/xray /usr/bin/xray-core /usr/local/bin/xray /opt/bin/xray /tmp/xray; do + for candidate in /usr/bin/xray /usr/bin/xray-core /usr/local/bin/xray /opt/bin/xray /tmp/owrt-xray/xray /tmp/xray; do if [ -x "$candidate" ]; then printf '%s' "$candidate" return @@ -159,6 +160,57 @@ xray_bin_path() { printf '%s' "$configured" } +fetch_file() { + local url dst + url="$1" + dst="$2" + if command -v wget >/dev/null 2>&1; then + wget -O "$dst" "$url" + return + fi + if command -v curl >/dev/null 2>&1; then + curl -fsSL "$url" -o "$dst" + return + fi + die "для скачивания нужен wget или curl" +} + +xray_release_asset() { + case "$(uname -m 2>/dev/null)" in + aarch64|arm64) printf '%s\n' "Xray-linux-arm64-v8a.zip" ;; + armv7l|armv7*) printf '%s\n' "Xray-linux-arm32-v7a.zip" ;; + armv6l|armv6*) printf '%s\n' "Xray-linux-arm32-v6.zip" ;; + armv5l|armv5*) printf '%s\n' "Xray-linux-arm32-v5.zip" ;; + x86_64|amd64) printf '%s\n' "Xray-linux-64.zip" ;; + i386|i686) printf '%s\n' "Xray-linux-32.zip" ;; + *) return 1 ;; + esac +} + +install_xray_tmp() { + local dir zip asset url + dir="/tmp/owrt-xray" + zip="$dir/xray.zip" + asset="$(xray_release_asset)" || die "не знаю готовый Xray asset для $(uname -m 2>/dev/null)" + url="https://github.com/XTLS/Xray-core/releases/latest/download/$asset" + + mkdir -p /var/lock /var/run "$dir" + if ! command -v unzip >/dev/null 2>&1; then + opkg update || die "не смог обновить opkg для установки unzip" + opkg install unzip || die "не смог поставить unzip" + fi + + fetch_file "$url" "$zip" + ( cd "$dir" && unzip -o "$zip" xray >/dev/null ) || die "не смог распаковать Xray" + chmod +x "$dir/xray" + "$dir/xray" version || die "скачанный Xray не запускается" + + uci set "$CONFIG.$SECTION.xray_bin=$dir/xray" + uci commit "$CONFIG" + printf 'OK: Xray поставлен в %s\n' "$dir/xray" + printf 'OK: xray_bin сохранен в /etc/config/owrtremote\n' +} + service_enabled() { /etc/init.d/owrt-remote enabled >/dev/null 2>&1 } @@ -431,6 +483,9 @@ case "$cmd" in doctor) doctor ;; + install-xray-tmp) + install_xray_tmp + ;; render-client) render_client_config "$@" ;; diff --git a/files/www/cgi-bin/owrt-remote b/files/www/cgi-bin/owrt-remote index ab2cfea..c0f1ec4 100644 --- a/files/www/cgi-bin/owrt-remote +++ b/files/www/cgi-bin/owrt-remote @@ -2,7 +2,7 @@ KEY_FILE="${KEY_FILE:-/etc/owrt-remote/web.key}" AGENT="${AGENT:-/usr/sbin/owrt-remote}" -OWRT_REMOTE_UI_VERSION="2026-06-29-balanced-header-v11" +OWRT_REMOTE_UI_VERSION="2026-06-29-xray-tmp-v12" PARAMS_FILE="${TMPDIR:-/tmp}/owrt-remote-cgi.$$" RESULT_TITLE="" RESULT_BODY="" @@ -166,6 +166,15 @@ run_action() { "$AGENT" doctor >"$output" 2>&1 || rc=$? set_result "Проверка" "$(cat "$output")" "ok" ;; + install_xray_tmp) + if "$AGENT" install-xray-tmp >"$output" 2>&1; then + "$AGENT" render-client >>"$output" 2>&1 || rc=$? + /etc/init.d/owrt-remote restart >>"$output" 2>&1 || rc=$? + else + rc=$? + fi + set_result "Xray установлен в /tmp" "$(cat "$output")" "ok" + ;; esac if [ "$rc" != "0" ]; then set_result "$RESULT_TITLE" "$(cat "$output")" "bad" @@ -310,6 +319,7 @@ EOF + Скачать Xray config EOF @@ -391,7 +401,7 @@ if [ "${REQUEST_METHOD:-GET}" = "POST" ]; then save_config run_action start ;; - start|stop|restart|heartbeat|doctor) + start|stop|restart|heartbeat|doctor|install_xray_tmp) run_action "$action" ;; esac diff --git a/install.sh b/install.sh index 67b41fe..5a8bd6e 100644 --- a/install.sh +++ b/install.sh @@ -137,3 +137,4 @@ fi info "LuCI: Службы -> OpenWrt Remote" info "Панель: http://$ip/cgi-bin/owrt-remote?key=$key" info "CLI: owrt-remote doctor" +info "Xray: если пишет 'нет Xray', нажми в панели 'Поставить Xray в /tmp' или выполни: owrt-remote install-xray-tmp"