Add OpenWrt Xray tmp installer
This commit is contained in:
1 parent
ca2b9f72cb
commit
6d7c59b17c
4 files changed
+76
-18
No files matched your search
@@ -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` в локальной панели роутера.
|
||||
|
||||
## Обновление
|
||||
|
||||
|
||||
@@ -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 "$@"
|
||||
;;
|
||||
|
||||
@@ -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
|
||||
<button class="btn bad" name="action" value="stop">Остановить</button>
|
||||
<button class="btn" name="action" value="heartbeat">Heartbeat</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>
|
||||
</form>
|
||||
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
|
||||
|
||||
@@ -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"
|
||||
Reference in new issue
Block a user