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

+56 -1
View File
@@ -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 "$@"
;;
+12 -2
View File
@@ -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