Add OpenWrt Xray tmp installer

This commit is contained in:
kzolotarev95 committed 2026-06-29 05:35:35 +04:00
1 parent ca2b9f72cb
commit 6d7c59b17c
4 files changed
+76 -18

No files matched your search

+7 -15
View File
@@ -176,6 +176,8 @@ owrt-remote heartbeat
## Xray на OpenWrt ## Xray на OpenWrt
OpenWrt Remote не кладет Xray автоматически в прошивку: бинарник большой, и на многих роутерах не хватает flash. Если в проверке видно `нет Xray: /usr/bin/xray`, поставь его одним из способов ниже.
Если хватает flash-памяти: Если хватает flash-памяти:
```sh ```sh
@@ -183,26 +185,16 @@ opkg update
opkg install xray-core opkg install xray-core
``` ```
Если flash мало, можно запустить Xray из RAM для теста: Если flash мало, можно запустить Xray из RAM:
```sh ```sh
mkdir -p /var/lock /var/run /tmp/owrt-xray owrt-remote install-xray-tmp
cd /tmp/owrt-xray owrt-remote render-client
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
/etc/init.d/owrt-remote restart /etc/init.d/owrt-remote restart
owrt-remote doctor
``` ```
Для другой архитектуры скачай подходящий архив Xray: То же самое можно сделать кнопкой `Поставить Xray в /tmp` в локальной панели роутера.
```text
https://github.com/XTLS/Xray-core/releases/latest
```
## Обновление ## Обновление
+56 -1
View File
@@ -17,6 +17,7 @@ usage() {
Использование: Использование:
owrt-remote status owrt-remote status
owrt-remote doctor owrt-remote doctor
owrt-remote install-xray-tmp
owrt-remote render-client [--stdout] owrt-remote render-client [--stdout]
owrt-remote run owrt-remote run
owrt-remote heartbeat owrt-remote heartbeat
@@ -145,7 +146,7 @@ xray_bin_path() {
printf '%s' "$configured" printf '%s' "$configured"
return return
fi 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 if [ -x "$candidate" ]; then
printf '%s' "$candidate" printf '%s' "$candidate"
return return
@@ -159,6 +160,57 @@ xray_bin_path() {
printf '%s' "$configured" 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() { service_enabled() {
/etc/init.d/owrt-remote enabled >/dev/null 2>&1 /etc/init.d/owrt-remote enabled >/dev/null 2>&1
} }
@@ -431,6 +483,9 @@ case "$cmd" in
doctor) doctor)
doctor doctor
;; ;;
install-xray-tmp)
install_xray_tmp
;;
render-client) render-client)
render_client_config "$@" render_client_config "$@"
;; ;;
+12 -2
View File
@@ -2,7 +2,7 @@
KEY_FILE="${KEY_FILE:-/etc/owrt-remote/web.key}" KEY_FILE="${KEY_FILE:-/etc/owrt-remote/web.key}"
AGENT="${AGENT:-/usr/sbin/owrt-remote}" 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.$$" PARAMS_FILE="${TMPDIR:-/tmp}/owrt-remote-cgi.$$"
RESULT_TITLE="" RESULT_TITLE=""
RESULT_BODY="" RESULT_BODY=""
@@ -166,6 +166,15 @@ run_action() {
"$AGENT" doctor >"$output" 2>&1 || rc=$? "$AGENT" doctor >"$output" 2>&1 || rc=$?
set_result "Проверка" "$(cat "$output")" "ok" 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 esac
if [ "$rc" != "0" ]; then if [ "$rc" != "0" ]; then
set_result "$RESULT_TITLE" "$(cat "$output")" "bad" set_result "$RESULT_TITLE" "$(cat "$output")" "bad"
@@ -310,6 +319,7 @@ EOF
<button class="btn bad" name="action" value="stop">Остановить</button> <button class="btn bad" name="action" value="stop">Остановить</button>
<button class="btn" name="action" value="heartbeat">Heartbeat</button> <button class="btn" name="action" value="heartbeat">Heartbeat</button>
<button class="btn" name="action" value="doctor">Проверка</button> <button class="btn" name="action" value="doctor">Проверка</button>
<button class="btn primary" name="action" value="install_xray_tmp">Поставить Xray в /tmp</button>
<a class="btn" href="?key=$(h "$key")&action=download_config">Скачать Xray config</a> <a class="btn" href="?key=$(h "$key")&action=download_config">Скачать Xray config</a>
</form> </form>
EOF EOF
@@ -391,7 +401,7 @@ if [ "${REQUEST_METHOD:-GET}" = "POST" ]; then
save_config save_config
run_action start run_action start
;; ;;
start|stop|restart|heartbeat|doctor) start|stop|restart|heartbeat|doctor|install_xray_tmp)
run_action "$action" run_action "$action"
;; ;;
esac esac
+1
View File
@@ -137,3 +137,4 @@ fi
info "LuCI: Службы -> OpenWrt Remote" info "LuCI: Службы -> OpenWrt Remote"
info "Панель: http://$ip/cgi-bin/owrt-remote?key=$key" info "Панель: http://$ip/cgi-bin/owrt-remote?key=$key"
info "CLI: owrt-remote doctor" info "CLI: owrt-remote doctor"
info "Xray: если пишет 'нет Xray', нажми в панели 'Поставить Xray в /tmp' или выполни: owrt-remote install-xray-tmp"