Publish v119 update safeguards and yichya Xray bootstrap fixes

This commit is contained in:
kzolotarev95 committed 2026-10-27 22:07:15 +04:00
1 parent 730b54c939
commit 5956daa8c2
73 files changed
+980 -306

No files matched your search

+2 -2
View File
@@ -15,7 +15,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-dashboard-layout-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-dashboard-layout-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
@@ -106,7 +106,7 @@ if [ "$healthy" -ne 1 ]; then
exit 1
fi
cmp "$source_file" "$target"
printf '\nBackup: %s\nDASHBOARD_LAYOUT_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nDASHBOARD_LAYOUT_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
+2 -2
View File
@@ -15,7 +15,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-dashboard-menu-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-dashboard-menu-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
@@ -108,7 +108,7 @@ if [ "$healthy" -ne 1 ]; then
exit 1
fi
cmp "$source_file" "$target"
printf '\nBackup: %s\nDASHBOARD_MENU_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nDASHBOARD_MENU_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
+2 -2
View File
@@ -15,7 +15,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-global-logs-ui-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-global-logs-ui-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
@@ -107,7 +107,7 @@ if [ "$healthy" -ne 1 ]; then
exit 1
fi
cmp "$source_file" "$target"
printf '\nBackup: %s\nGLOBAL_LOGS_VPS_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nGLOBAL_LOGS_VPS_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
+2 -2
View File
@@ -13,7 +13,7 @@ $RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
backup=/root/owrt-remote-backup-before-global-logs-stop-v118
backup=/root/owrt-remote-backup-before-global-logs-stop-v119
items='cgi agent init logs.sh logs-init luci'
changed=0
phase=preflight
@@ -104,7 +104,7 @@ if [ '__ACTION__' = Install ]; then
command -v base64 >/dev/null
command -v jsonfilter >/dev/null
grep -F -q 'globalLogsToggle' "$stage/cgi"
for item in cgi luci; do grep -F -q 'v118' "$stage/$item"; done
for item in cgi luci; do grep -F -q 'v119' "$stage/$item"; done
grep -F -q 'LOG_KEEP_SECONDS=86400' "$stage/logs.sh"
grep -F -q 'log_sync_loop' "$stage/logs.sh"
grep -F -q 'sync_global_logs' "$stage/agent"
+4 -4
View File
@@ -6,7 +6,7 @@ param(
$ErrorActionPreference = 'Stop'
$RepoRoot = Split-Path -Parent $PSScriptRoot
$UploadName = 'owrt-group-colors-v118-' + [guid]::NewGuid().ToString('N')
$UploadName = 'owrt-group-colors-v119-' + [guid]::NewGuid().ToString('N')
$StageRoot = Join-Path ([System.IO.Path]::GetTempPath()) $UploadName
$Utf8 = [System.Text.UTF8Encoding]::new($false)
@@ -15,7 +15,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-group-colors-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-group-colors-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
@@ -57,7 +57,7 @@ if [ '__ACTION__' = Install ]; then
from pathlib import Path
import sys
source = Path(sys.argv[1]).read_text(encoding='utf-8')
required = ('v118', '#routerForm select option,#routerGroupFilter option', 'background-color:#221a34', 'id="backupDownload"', 'id="backupRestore"')
required = ('v119', '#routerForm select option,#routerGroupFilter option', 'background-color:#221a34', 'id="backupDownload"', 'id="backupRestore"')
if 'class="backupCmds"' in source:
print('Old backup command instructions remain in candidate', file=sys.stderr)
raise SystemExit(1)
@@ -106,7 +106,7 @@ if [ "$healthy" -ne 1 ]; then
exit 1
fi
cmp "$source_file" "$target"
printf '\nBackup: %s\nGROUP_COLORS_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nGROUP_COLORS_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
+1 -1
View File
@@ -13,7 +13,7 @@ $RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
backup=/root/owrt-remote-backup-before-heartbeat-redirect-v118
backup=/root/owrt-remote-backup-before-heartbeat-redirect-v119
agent=/usr/sbin/owrt-remote
wan=/usr/lib/owrt-remote/wan.sh
changed=0
+1 -1
View File
@@ -17,7 +17,7 @@ $RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
backup_dir=/root/owrt-remote-backup-before-heartbeat-transport-v118
backup_dir=/root/owrt-remote-backup-before-heartbeat-transport-v119
changed=0
phase=preflight
item_path() {
+9 -9
View File
@@ -5,7 +5,7 @@ param(
[string]$PinnedVpsHost = '193.233.82.38',
[ValidatePattern('^[a-zA-Z0-9_-]+$')][string]$WanInterface = 'wan',
[switch]$PreserveConnectionSettings,
[ValidatePattern('^[a-zA-Z0-9_-]+$')][string]$BackupName = 'host-policy-v118',
[ValidatePattern('^[a-zA-Z0-9_-]+$')][string]$BackupName = 'host-policy-v119',
[switch]$PrepareOnly
)
@@ -90,7 +90,7 @@ test -s "$config"
if [ '__ACTION__' = Install ]; then
for item in agent wan.sh cgi init; do test -s "$stage/$item"; sh -n "$stage/$item"; done
test -s "$stage/luci"
for item in cgi luci; do grep -F -q 'v118' "$stage/$item"; done
for item in cgi luci; do grep -F -q 'v119' "$stage/$item"; done
# curl is needed to preserve HTTPS SNI and bypass the local DNS/proxy.
if ! command -v curl >/dev/null 2>&1; then
if command -v opkg >/dev/null 2>&1; then opkg update && opkg install curl ca-bundle
@@ -156,16 +156,16 @@ if [ '__ACTION__' = Install ]; then
exit 1
fi
/usr/sbin/owrt-remote status
grep -F -q 'v118' /www/cgi-bin/owrt-remote
grep -F -q 'v118' /www/luci-static/resources/view/owrt_remote.js
echo HOST_POLICY_ROUTER_V118_OK
grep -F -q 'v119' /www/cgi-bin/owrt-remote
grep -F -q 'v119' /www/luci-static/resources/view/owrt_remote.js
echo HOST_POLICY_ROUTER_V119_OK
else
test -f "$backup/complete"
save_files "$stage/previous"
changed=1
restore_files "$backup"
/usr/sbin/owrt-remote status
echo HOST_POLICY_ROUTER_V118_ROLLBACK_OK
echo HOST_POLICY_ROUTER_V119_ROLLBACK_OK
fi
'@
} else {
@@ -180,7 +180,7 @@ fi
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-host-policy-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-host-policy-v119
changed=0
cleanup() {
code=$?
@@ -200,7 +200,7 @@ test -s "$target"
python_bin=/opt/owrt-remote/venv/bin/python
[ -x "$python_bin" ] || python_bin=python3
if [ '__ACTION__' = Install ]; then
grep -F -q 'v118' "$stage/hub.py"
grep -F -q 'v119' "$stage/hub.py"
"$python_bin" -m py_compile "$stage/hub.py"
OWRT_HOST_POLICY_HUB_SOURCE="$stage/hub.py" "$python_bin" "$stage/test_host_policy.py" HostPolicyTests -v
OWRT_RESOURCE_HUB_SOURCE="$stage/hub.py" "$python_bin" "$stage/resources.py" -v
@@ -226,7 +226,7 @@ for attempt in 1 2 3 4 5 6 7 8 9 10; do
done
test "$healthy" = 1
cmp "$candidate" "$target"
printf '\nHOST_POLICY_VPS_V118_%s_OK\n' '__ACTION__'
printf '\nHOST_POLICY_VPS_V119_%s_OK\n' '__ACTION__'
'@
}
+2 -2
View File
@@ -15,7 +15,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-self-update-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-self-update-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
@@ -107,7 +107,7 @@ if [ "$healthy" -ne 1 ]; then
exit 1
fi
cmp "$source_file" "$target"
printf '\nBackup: %s\nHUB_SELF_UPDATE_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nHUB_SELF_UPDATE_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
+6 -6
View File
@@ -34,7 +34,7 @@ if ($Target -eq 'Router') {
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
backup=/root/owrt-remote-backup-before-hub-url-v118
backup=/root/owrt-remote-backup-before-hub-url-v119
chmod 700 "$stage"
config=/etc/config/owrtremote
changed=0
@@ -99,7 +99,7 @@ if [ '__ACTION__' = Install ]; then
grep -F -q 'heartbeat_set_url_if_changed()' "$stage/agent"
grep -F -q 'reason=https-downgrade' "$stage/agent"
for item in agent wan.sh; do grep -F -q -- '--post301' "$stage/$item"; done
for item in cgi luci; do grep -F -q 'v118' "$stage/$item"; done
for item in cgi luci; do grep -F -q 'v119' "$stage/$item"; done
if [ ! -e "$backup" ]; then
save_files "$stage/retained-backup"
mv "$stage/retained-backup" "$backup"
@@ -138,7 +138,7 @@ else
changed=1
restore_files "$backup"
fi
printf '\nBackup: %s\nHUB_URL_ROUTER_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nHUB_URL_ROUTER_V119_%s_OK\n' "$backup" '__ACTION__'
'@
} else {
$Payloads = @{
@@ -152,7 +152,7 @@ set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
chmod 700 "$stage"
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-url-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-url-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
cleanup() {
@@ -174,7 +174,7 @@ python_bin=/opt/owrt-remote/venv/bin/python
[ -x "$python_bin" ] || python_bin=python3
if [ '__ACTION__' = Install ]; then
grep -F -q 'def router_hub_origins(' "$stage/hub.py"
grep -F -q 'v118' "$stage/hub.py"
grep -F -q 'v119' "$stage/hub.py"
"$python_bin" -m py_compile "$stage/hub.py"
OWRT_HOST_POLICY_HUB_SOURCE="$stage/hub.py" "$python_bin" "$stage/host_policy.py" HostPolicyTests -v
OWRT_RESOURCE_HUB_SOURCE="$stage/hub.py" "$python_bin" "$stage/resources.py" IntegrationTests -v
@@ -198,7 +198,7 @@ for attempt in 1 2 3 4 5 6 7 8 9 10; do
done
test "$healthy" = 1
cmp "$source_file" "$target"
printf '\nBackup: %s\nHUB_URL_VPS_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nHUB_URL_VPS_V119_%s_OK\n' "$backup" '__ACTION__'
'@
}
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action).Replace('__HUB_URL__', $HubUrl)
+1 -1
View File
@@ -17,7 +17,7 @@ $RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
backup_dir=/root/owrt-remote-backup-before-log-collector-v118
backup_dir=/root/owrt-remote-backup-before-log-collector-v119
changed=0
phase=preflight
items='logs.sh logs-init'
+2 -2
View File
@@ -14,7 +14,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-online-status-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-online-status-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
cleanup() {
@@ -59,7 +59,7 @@ for attempt in 1 2 3 4 5 6 7 8 9 10; do
done
test "$healthy" = 1
cmp "$source_file" "$target"
printf '\nBackup: %s\nONLINE_STATUS_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nONLINE_STATUS_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
try {
+2 -2
View File
@@ -15,7 +15,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-password-logout-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-password-logout-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
@@ -105,7 +105,7 @@ if [ "$healthy" -ne 1 ]; then
exit 1
fi
cmp "$source_file" "$target"
printf '\nBackup: %s\nPASSWORD_LOGOUT_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nPASSWORD_LOGOUT_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
+2 -2
View File
@@ -15,7 +15,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-persistent-logs-sync-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-persistent-logs-sync-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
@@ -144,7 +144,7 @@ if [ "$healthy" -ne 1 ]; then
exit 1
fi
cmp "$source_file" "$target"
printf '\nBackup: %s\nPERSISTENT_LOGS_VPS_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nPERSISTENT_LOGS_VPS_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
+2 -2
View File
@@ -13,7 +13,7 @@ $RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
backup=/root/owrt-remote-backup-before-persistent-logs-v118
backup=/root/owrt-remote-backup-before-persistent-logs-v119
items='cgi agent logs.sh logs-init luci'
changed=0
phase=preflight
@@ -106,7 +106,7 @@ if [ '__ACTION__' = Install ]; then
exit 1
fi
grep -F -q 'globalLogsToggle' "$stage/cgi"
for item in cgi luci; do grep -F -q 'v118' "$stage/$item"; done
for item in cgi luci; do grep -F -q 'v119' "$stage/$item"; done
grep -F -q 'LOG_BUFFER_LIMIT=16384' "$stage/logs.sh"
grep -F -q 'LOG_KEEP_SECONDS=86400' "$stage/logs.sh"
grep -F -q 'log_sync_loop' "$stage/logs.sh"
+6 -6
View File
@@ -17,8 +17,8 @@ if ($Action -eq 'Install') {
set -Eeuo pipefail
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-recaptcha-v3-v118
captcha_backup=/opt/owrt-remote/captcha-before-recaptcha-v3-v118.json
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-recaptcha-v3-v119
captcha_backup=/opt/owrt-remote/captcha-before-recaptcha-v3-v119.json
candidate=$target.new-__UPLOAD_NAME__
changed=0
cleanup() {
@@ -45,7 +45,7 @@ if [ ! -x "$python_bin" ]; then python_bin=python3; fi
import ast, pathlib, sys
source = pathlib.Path(sys.argv[1]).read_text(encoding='utf-8')
tree = ast.parse(source)
assert 'v118' in source
assert 'v119' in source
assert 'v108' not in source
assert 'CAPTCHA_MODE_RECAPTCHA_V3' in source
assert 'prepareLoginRecaptcha' in source
@@ -88,7 +88,7 @@ pid=$(systemctl show owrt-remote -p MainPID --value)
test "$pid" -gt 0
printf 'PID=%s FD=%s\n' "$pid" "$(find /proc/$pid/fd -maxdepth 1 -type l | wc -l)"
systemctl --no-pager --full status owrt-remote | sed -n '1,16p'
echo RECAPTCHA_V3_V118_OK
echo RECAPTCHA_V3_V119_OK
'@
} elseif ($Action -eq 'Rollback') {
$RemoteScript = @'
@@ -96,8 +96,8 @@ echo RECAPTCHA_V3_V118_OK
set -Eeuo pipefail
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-recaptcha-v3-v118
captcha_backup=/opt/owrt-remote/captcha-before-recaptcha-v3-v118.json
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-recaptcha-v3-v119
captcha_backup=/opt/owrt-remote/captcha-before-recaptcha-v3-v119.json
candidate=$target.rollback-__UPLOAD_NAME__
changed=0
restore_captcha() {
+4 -4
View File
@@ -18,7 +18,7 @@ if ($Action -eq 'Install') {
set -Eeuo pipefail
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-resource-fix-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-resource-fix-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
cleanup() {
@@ -45,7 +45,7 @@ if [ ! -x "$python_bin" ]; then python_bin=python3; fi
import ast, pathlib, sys
source = pathlib.Path(sys.argv[1]).read_text(encoding='utf-8')
tree = ast.parse(source)
assert 'v118' in source
assert 'v119' in source
assert 'v108' not in source
factory = next(node for node in tree.body if isinstance(node, ast.FunctionDef) and node.name == 'connect')
assert any(isinstance(item, ast.Name) and item.id == 'contextmanager' for item in factory.decorator_list)
@@ -78,7 +78,7 @@ pid=$(systemctl show owrt-remote -p MainPID --value)
test "$pid" -gt 0
printf 'PID=%s FD=%s\n' "$pid" "$(find /proc/$pid/fd -maxdepth 1 -type l | wc -l)"
systemctl --no-pager --full status owrt-remote | sed -n '1,16p'
echo RESOURCE_FIX_V118_OK
echo RESOURCE_FIX_V119_OK
'@
} elseif ($Action -eq 'Rollback') {
$RemoteScript = @'
@@ -86,7 +86,7 @@ echo RESOURCE_FIX_V118_OK
set -Eeuo pipefail
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-resource-fix-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-resource-fix-v119
candidate=$target.rollback-__UPLOAD_NAME__
changed=0
cleanup() {
+2 -2
View File
@@ -15,7 +15,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-router-card-ui-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-router-card-ui-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
@@ -106,7 +106,7 @@ if [ "$healthy" -ne 1 ]; then
exit 1
fi
cmp "$source_file" "$target"
printf '\nBackup: %s\nROUTER_CARD_UI_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nROUTER_CARD_UI_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
+2 -2
View File
@@ -15,7 +15,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-router-reboot-all-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-router-reboot-all-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
@@ -125,7 +125,7 @@ if [ "$healthy" -ne 1 ]; then
exit 1
fi
cmp "$source_file" "$target"
printf '\nBackup: %s\nROUTER_UPDATES_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nROUTER_UPDATES_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
+187
View File
@@ -0,0 +1,187 @@
param(
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string]$Vps,
[ValidateSet('Install', 'Rollback')][string]$Action = 'Install',
[switch]$PrepareOnly
)
$ErrorActionPreference = 'Stop'
$RepoRoot = Split-Path -Parent $PSScriptRoot
$UploadName = 'owrt-update-status-ui-' + [guid]::NewGuid().ToString('N')
$StageRoot = Join-Path ([System.IO.Path]::GetTempPath()) $UploadName
$Utf8 = [System.Text.UTF8Encoding]::new($false)
$RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-update-status-ui-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
show_failure() {
echo '--- owrt-remote status ---' >&2
systemctl --no-pager -l status owrt-remote >&2 || true
echo '--- owrt-remote journal ---' >&2
journalctl -u owrt-remote -n 80 --no-pager -l >&2 || true
}
cleanup() {
code=$?
trap - EXIT
if [ "$code" -ne 0 ]; then
echo "Remote step failed with rc=$code" >&2
show_failure
fi
if [ "$code" -ne 0 ] && [ "$changed" = 1 ] && [ -s "$stage/previous.py" ]; then
echo 'Restoring the previous Hub file...' >&2
cp -p "$stage/previous.py" "$candidate"
mv -f "$candidate" "$target"
systemctl restart owrt-remote || true
fi
rm -f "$candidate"
rm -rf "$stage"
exit "$code"
}
trap cleanup EXIT
test -s "$target"
python_bin=/opt/owrt-remote/venv/bin/python
[ -x "$python_bin" ] || python_bin=python3
if [ '__ACTION__' = Install ]; then
test -s "$stage/hub.py"
echo 'Validating candidate...'
"$python_bin" -m py_compile "$stage/hub.py"
"$python_bin" - "$stage/hub.py" <<'PY'
from pathlib import Path
import sys
source = Path(sys.argv[1]).read_text(encoding='utf-8')
required = (
"class HubUpdateManager:",
"def run_hub_update_worker(",
"function initHubUpdate()",
"panel-update-worker",
"hub_update_api",
"X-Hub-Update-CSRF",
"def hub_update_require_version(",
"def hub_update_older_version(",
": state.checked && !state.error ?",
"else if (state.checked && !state.checking) message('');",
)
missing = [marker for marker in required if marker not in source]
if missing:
for marker in missing:
print('Missing marker:', repr(marker), file=sys.stderr)
raise SystemExit(1)
print('Candidate validation OK')
PY
if [ ! -e "$backup" ]; then
cp -p "$target" "$backup"
fi
source_file="$stage/hub.py"
else
test -s "$backup"
"$python_bin" -m py_compile "$backup"
source_file="$backup"
fi
expected_revision=$("$python_bin" - "$source_file" <<'PY'
import hashlib
from pathlib import Path
import sys
print(hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest())
PY
)
cp -p "$target" "$stage/previous.py"
cp "$source_file" "$candidate"
chmod 0755 "$candidate"
changed=1
mv -f "$candidate" "$target"
echo 'Restarting owrt-remote...'
if ! systemctl restart owrt-remote; then
show_failure
exit 1
fi
healthy=0
for attempt in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
if systemctl is-active --quiet owrt-remote && "$python_bin" - "$expected_revision" > "$stage/health-check" 2>&1 <<'PY'
import json
import sys
import urllib.request
try:
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
with opener.open('http://127.0.0.1:8088/health?panel-update=1', timeout=3) as response:
data = json.loads(response.read(4096))
revision = data.get('revision', '')
if not data.get('ok') or revision != sys.argv[1]:
raise RuntimeError('Running Hub revision does not match the uploaded file: '
+ (revision or '(not reported)') + '; expected ' + sys.argv[1])
print('Running Hub revision verified: ' + revision)
except Exception as error:
print('Health verification failed: ' + str(error), file=sys.stderr)
raise SystemExit(1)
PY
then
healthy=1
break
fi
sleep 2
done
if [ "$healthy" -ne 1 ]; then
echo 'The uploaded Hub build did not become ready; installation was not confirmed.' >&2
cat "$stage/health-check" >&2 2>/dev/null || true
show_failure
exit 1
fi
cat "$stage/health-check"
cmp "$source_file" "$target"
printf '\nBackup: %s\nUPDATE_STATUS_UI_V119_%s_OK\n' "$backup" '__ACTION__'
if [ '__ACTION__' = Install ]; then
echo 'Reload the Hub page (Ctrl+F5) to load the new UI.'
echo 'This fix is LOCAL. The panel update button can replace it with the published repository build.'
echo 'For a full local current-version test use test-hub-self-update.ps1 -Action Retest.'
fi
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
try {
[System.IO.Directory]::CreateDirectory($StageRoot) | Out-Null
[System.IO.File]::WriteAllText(
(Join-Path $StageRoot 'run.sh'),
$RemoteScript.Replace("`r`n", "`n") + "`n",
$Utf8
)
if ($Action -eq 'Install') {
$Content = [System.IO.File]::ReadAllText((Join-Path $RepoRoot 'vps\owrt-remote-hub.py')).Replace("`r`n", "`n")
[System.IO.File]::WriteAllText((Join-Path $StageRoot 'hub.py'), $Content, $Utf8)
}
if ($PrepareOnly) {
Write-Host "Prepared only: $StageRoot"
return
}
& scp -O -r -- $StageRoot "${Vps}:/tmp/"
if ($LASTEXITCODE -ne 0) { throw 'Upload failed. VPS was not changed.' }
& ssh -T -o ConnectTimeout=10 $Vps "sh /tmp/$UploadName/run.sh"
if ($LASTEXITCODE -ne 0) { throw "$Action failed. See the output above; success was not confirmed." }
Write-Host "Update status UI $Action finished successfully."
}
finally {
if (-not $PrepareOnly) {
$Resolved = [System.IO.Path]::GetFullPath($StageRoot)
$Expected = [System.IO.Path]::GetFullPath((Join-Path ([System.IO.Path]::GetTempPath()) $UploadName))
if ($Resolved -ne $Expected -or (Split-Path -Leaf $Resolved) -ne $UploadName) {
throw 'Unsafe staging cleanup path.'
}
if (Test-Path -LiteralPath $Resolved) {
Remove-Item -LiteralPath $Resolved -Recurse -Force
}
}
}
@@ -7,7 +7,7 @@ param(
$ErrorActionPreference = 'Stop'
$RepoRoot = Split-Path -Parent $PSScriptRoot
$UploadName = 'owrt-version-v118-' + [guid]::NewGuid().ToString('N')
$UploadName = 'owrt-version-v119-' + [guid]::NewGuid().ToString('N')
$StageRoot = Join-Path ([System.IO.Path]::GetTempPath()) $UploadName
$Utf8 = [System.Text.UTF8Encoding]::new($false)
@@ -16,7 +16,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
@@ -58,8 +58,9 @@ if [ '__ACTION__' = Install ]; then
from pathlib import Path
import sys
source = Path(sys.argv[1]).read_text(encoding='utf-8')
required = ('v118',)
if 'v' + '117' in source:
required = ('v119', 'def hub_update_require_version(', 'def hub_update_older_version(',
"else if (state.checked && !state.checking) message('');")
if 'v' + '118' in source:
print('Old UI version remains in candidate', file=sys.stderr)
raise SystemExit(1)
missing = [marker for marker in required if marker not in source]
@@ -79,6 +80,14 @@ else
source_file="$backup"
fi
expected_revision=$("$python_bin" - "$source_file" <<'PY'
import hashlib
from pathlib import Path
import sys
print(hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest())
PY
)
cp -p "$target" "$stage/previous.py"
cp "$source_file" "$candidate"
chmod 0755 "$candidate"
@@ -92,26 +101,46 @@ fi
healthy=0
for attempt in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
if systemctl is-active --quiet owrt-remote && curl -fsS --max-time 5 http://127.0.0.1:8088/health; then
if systemctl is-active --quiet owrt-remote && "$python_bin" - "$expected_revision" > "$stage/health-check" 2>&1 <<'PY'
import json
import sys
import urllib.request
try:
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
with opener.open('http://127.0.0.1:8088/health?panel-update=1', timeout=3) as response:
data = json.loads(response.read(4096))
revision = data.get('revision', '')
if not data.get('ok') or revision != sys.argv[1]:
raise RuntimeError('Running Hub revision does not match the uploaded file: '
+ (revision or '(not reported)') + '; expected ' + sys.argv[1])
print('Running Hub revision verified: ' + revision)
except Exception as error:
print('Health verification failed: ' + str(error), file=sys.stderr)
raise SystemExit(1)
PY
then
healthy=1
break
fi
sleep 2
done
if [ "$healthy" -ne 1 ]; then
echo 'Health check did not become ready.' >&2
echo 'The uploaded Hub build did not become ready; installation was not confirmed.' >&2
cat "$stage/health-check" >&2 2>/dev/null || true
show_failure
exit 1
fi
cat "$stage/health-check"
cmp "$source_file" "$target"
printf '\nBackup: %s\nHUB_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nHUB_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RouterScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
backup=/root/owrt-remote-backup-before-v118
backup=/root/owrt-remote-backup-before-v119
cgi=/www/cgi-bin/owrt-remote
luci=/www/luci-static/resources/view/owrt_remote.js
changed=0
@@ -135,9 +164,9 @@ test -s "$cgi"
test -s "$luci"
if [ '__ACTION__' = Install ]; then
sh -n "$stage/cgi"
grep -F -q 'v118' "$stage/cgi"
grep -F -q 'v118' "$stage/luci"
if grep -F -q 'v''117' "$stage/cgi" "$stage/luci"; then
grep -F -q 'v119' "$stage/cgi"
grep -F -q 'v119' "$stage/luci"
if grep -F -q 'v''118' "$stage/cgi" "$stage/luci"; then
echo 'Old UI version remains in candidate.' >&2
exit 1
fi
@@ -170,7 +199,7 @@ cmp "$source_dir/cgi" "$cgi"
cmp "$source_dir/luci" "$luci"
[ ! -x /etc/init.d/rpcd ] || /etc/init.d/rpcd restart || true
[ ! -x /etc/init.d/uhttpd ] || /etc/init.d/uhttpd reload || true
printf '\nBackup: %s\nROUTER_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nROUTER_V119_%s_OK\n' "$backup" '__ACTION__'
'@
if ($PSCmdlet.ParameterSetName -eq 'Router') {
@@ -211,7 +240,7 @@ try {
if ($LASTEXITCODE -ne 0) { throw 'Upload failed. Target was not changed.' }
& ssh -T -o ConnectTimeout=10 $TargetMachine "sh /tmp/$UploadName/run.sh"
if ($LASTEXITCODE -ne 0) { throw "$Action failed. See the output above; success was not confirmed." }
Write-Host "Version v118 $Action finished successfully. Refresh the panel."
Write-Host "Version v119 $Action finished successfully. Refresh the panel."
}
finally {
if (-not $PrepareOnly) {
+2 -2
View File
@@ -15,7 +15,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-vps-resources-live-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-vps-resources-live-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
@@ -107,7 +107,7 @@ if [ "$healthy" -ne 1 ]; then
exit 1
fi
cmp "$source_file" "$target"
printf '\nBackup: %s\nVPS_RESOURCES_LIVE_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nVPS_RESOURCES_LIVE_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
+3 -3
View File
@@ -14,7 +14,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-vps-widgets-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-vps-widgets-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
cleanup() {
@@ -37,7 +37,7 @@ python_bin=/opt/owrt-remote/venv/bin/python
[ -x "$python_bin" ] || python_bin=python3
if [ '__ACTION__' = Install ]; then
test -s "$stage/hub.py"
grep -F -q 'v118' "$stage/hub.py"
grep -F -q 'v119' "$stage/hub.py"
"$python_bin" -m py_compile "$stage/hub.py"
OWRT_VPS_WIDGETS_HUB_SOURCE="$stage/hub.py" "$python_bin" "$stage/tests.py" -v
if [ ! -e "$backup" ]; then cp -p "$target" "$backup"; fi
@@ -67,7 +67,7 @@ if [ '__ACTION__' = Install ]; then
code=$(curl -sS --max-time 5 -o "$stage/response.json" -w '%{http_code}' http://127.0.0.1:8088/api/vps/resources)
test "$code" = 401
fi
printf '\nVPS_WIDGETS_V118_%s_OK\n' '__ACTION__'
printf '\nVPS_WIDGETS_V119_%s_OK\n' '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
try {
+1 -1
View File
@@ -14,7 +14,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/usr/lib/owrt-remote/wan.sh
backup_dir=/root/owrt-remote-backup-before-wan-dns-v118
backup_dir=/root/owrt-remote-backup-before-wan-dns-v119
changed=0
phase=preflight
heartbeat_pid() {
+2 -2
View File
@@ -20,7 +20,7 @@ $RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
backup=/root/owrt-remote-backup-before-wan-multi-v118
backup=/root/owrt-remote-backup-before-wan-multi-v119
config=/etc/config/owrtremote
changed=0
item_path() {
@@ -81,7 +81,7 @@ test -s "$config"
if [ '__ACTION__' = Install ]; then
for item in agent wan.sh cgi hotplug; do test -s "$stage/$item"; sh -n "$stage/$item"; done
test -s "$stage/luci"
for item in cgi luci; do grep -F -q 'v118' "$stage/$item"; done
for item in cgi luci; do grep -F -q 'v119' "$stage/$item"; done
grep -F -q 'wan_interface_picker' "$stage/cgi"
grep -F -q 'wan_select_interface()' "$stage/wan.sh"
grep -F -q 'wan_reconcile_xray()' "$stage/agent"
+1 -1
View File
@@ -17,7 +17,7 @@ $RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
backup_dir=/root/owrt-remote-backup-before-wan-recovery-v118
backup_dir=/root/owrt-remote-backup-before-wan-recovery-v119
changed=0
phase=preflight
item_path() {
+1 -1
View File
@@ -17,7 +17,7 @@ $RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
backup=/root/owrt-remote-backup-before-wan-stability-v118
backup=/root/owrt-remote-backup-before-wan-stability-v119
config=/etc/config/owrtremote
changed=0
fail() {
+2 -2
View File
@@ -15,7 +15,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/opt/owrt-remote/owrt-remote-hub.py
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-web-push-v118
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-web-push-v119
candidate=$target.new-__UPLOAD_NAME__
changed=0
@@ -72,7 +72,7 @@ for attempt in 1 2 3 4 5 6 7 8 9 10; do
done
test "$healthy" = 1
cmp "$source_file" "$target"
printf '\nBackup: %s\nWEB_PUSH_V118_%s_OK\n' "$backup" '__ACTION__'
printf '\nBackup: %s\nWEB_PUSH_V119_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
+1 -1
View File
@@ -14,7 +14,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/www/cgi-bin/owrt-remote
backup_dir=/root/owrt-remote-backup-before-xray-apply-v118
backup_dir=/root/owrt-remote-backup-before-xray-apply-v119
backup=$backup_dir/owrt-remote
candidate=$target.new-__UPLOAD_NAME__
changed=0
+1 -1
View File
@@ -14,7 +14,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/usr/sbin/owrt-remote
backup_dir=/root/owrt-remote-backup-before-xray-boot-v118
backup_dir=/root/owrt-remote-backup-before-xray-boot-v119
changed=0
phase=preflight
heartbeat_pid() {
+1 -1
View File
@@ -14,7 +14,7 @@ $RemoteScript = @'
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/www/cgi-bin/owrt-remote
backup_dir=/root/owrt-remote-backup-before-xray-mobile-v118
backup_dir=/root/owrt-remote-backup-before-xray-mobile-v119
backup=$backup_dir/owrt-remote
candidate=$target.new-__UPLOAD_NAME__
changed=0
+110
View File
@@ -0,0 +1,110 @@
param(
[ValidateNotNullOrEmpty()][string]$Router = 'root@192.168.2.1',
[ValidateSet('Install', 'Rollback')][string]$Action = 'Install',
[switch]$PrepareOnly
)
$ErrorActionPreference = 'Stop'
$RepoRoot = Split-Path -Parent $PSScriptRoot
$UploadName = 'owrt-xray-source-' + [guid]::NewGuid().ToString('N')
$StageRoot = Join-Path ([System.IO.Path]::GetTempPath()) $UploadName
$Utf8 = [System.Text.UTF8Encoding]::new($false)
$RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
target=/usr/sbin/owrt-remote
backup_dir=/root/owrt-remote-backup-before-xray-source-v119
runtime=/tmp/owrt-xray/xray
changed=0
phase=preflight
restore_runtime() {
if [ -s "$backup_dir/xray" ]; then
mkdir -p "$(dirname "$runtime")"
cp -p "$backup_dir/xray" "$runtime.new-__UPLOAD_NAME__" && chmod 755 "$runtime.new-__UPLOAD_NAME__" && mv -f "$runtime.new-__UPLOAD_NAME__" "$runtime"
uci set owrtremote.main.xray_bin=/tmp/owrt-xray/xray >/dev/null 2>&1 || true
uci commit owrtremote >/dev/null 2>&1 || true
fi
}
cleanup() {
code=$?
trap - EXIT
if [ "$code" -ne 0 ]; then
printf 'Failed during %s (rc=%s).\n' "$phase" "$code" >&2
if [ "$changed" = 1 ] && [ -s "$stage/previous" ]; then
echo 'Restoring the previous agent. The working Xray/configuration is retained.' >&2
cp -p "$stage/previous" "$target.new-__UPLOAD_NAME__" && mv -f "$target.new-__UPLOAD_NAME__" "$target" || true
restore_runtime || true
fi
fi
rm -f "$target.new-__UPLOAD_NAME__"
rm -rf "$stage"
exit "$code"
}
trap cleanup EXIT
trap 'exit 1' INT TERM
test -s "$target"
if [ '__ACTION__' = Install ]; then
test -s "$stage/agent"
sh -n "$stage/agent"
grep -Fq 'https://github.com/yichya/openwrt-xray' "$stage/agent"
grep -Fq 'xray_package_extract_binary()' "$stage/agent"
if [ ! -e "$backup_dir" ]; then
mkdir -p "$stage/retained"
chmod 700 "$stage/retained"
cp -p "$target" "$stage/retained/agent"
if [ -s "$runtime" ]; then cp -p "$runtime" "$stage/retained/xray"; fi
: >"$stage/retained/complete"
mv "$stage/retained" "$backup_dir"
fi
test -f "$backup_dir/complete" && test -s "$backup_dir/agent" || { echo 'Incomplete backup. Nothing changed.' >&2; exit 1; }
source_file=$stage/agent
else
test -f "$backup_dir/complete" && test -s "$backup_dir/agent" || { echo "No complete backup: $backup_dir. Nothing changed." >&2; exit 1; }
sh -n "$backup_dir/agent"
source_file=$backup_dir/agent
fi
cp -p "$target" "$stage/previous"
phase=install
changed=1
cp "$source_file" "$target.new-__UPLOAD_NAME__"
chmod 755 "$target.new-__UPLOAD_NAME__"
mv -f "$target.new-__UPLOAD_NAME__" "$target"
phase=verify
sh -n "$target"
cmp "$source_file" "$target"
if [ '__ACTION__' = Install ]; then
phase=xray-package
# Force one controlled download from yichya/openwrt-xray now. The package
# is validated before /tmp/owrt-xray/xray and UCI are changed.
"$target" install-xray-tmp
else
restore_runtime
fi
printf 'Backup: %s\n' "$backup_dir"
printf '\nXRAY_SOURCE_ROUTER_%s_OK\n' '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
try {
[System.IO.Directory]::CreateDirectory($StageRoot) | Out-Null
[System.IO.File]::WriteAllText((Join-Path $StageRoot 'run.sh'), $RemoteScript.Replace("`r`n", "`n") + "`n", $Utf8)
if ($Action -eq 'Install') {
$Content = [System.IO.File]::ReadAllText((Join-Path $RepoRoot 'files\usr\sbin\owrt-remote')).Replace("`r`n", "`n")
[System.IO.File]::WriteAllText((Join-Path $StageRoot 'agent'), $Content, $Utf8)
}
if ($PrepareOnly) { Write-Host "Prepared only: $StageRoot"; return }
& scp -O -r -- $StageRoot "${Router}:/tmp/"
if ($LASTEXITCODE -ne 0) { throw 'Upload failed. The installation has not started.' }
& ssh -T -o ConnectTimeout=10 $Router "sh /tmp/$UploadName/run.sh"
if ($LASTEXITCODE -ne 0) { throw "$Action failed. See the output above; success was not confirmed." }
Write-Host "Xray source fix $Action finished successfully."
} finally {
if (-not $PrepareOnly) {
$Resolved = [System.IO.Path]::GetFullPath($StageRoot)
$Expected = [System.IO.Path]::GetFullPath((Join-Path ([System.IO.Path]::GetTempPath()) $UploadName))
if ($Resolved -ne $Expected -or (Split-Path -Leaf $Resolved) -ne $UploadName) { throw 'Unsafe staging cleanup path.' }
if (Test-Path -LiteralPath $Resolved) { Remove-Item -LiteralPath $Resolved -Recurse -Force }
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ $RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
backup_dir=/root/owrt-remote-backup-before-xray-validation-v118
backup_dir=/root/owrt-remote-backup-before-xray-validation-v119
changed=0
phase=preflight
item_path() {
+39 -15
View File
@@ -73,7 +73,19 @@ except Exception:
APP_NAME = "OpenWrt Remote Hub"
RAW_REPO_BASE = os.environ.get("RAW_REPO_BASE", "https://raw.githubusercontent.com/kzolotarev95/luci-app-owrt-remote/main").rstrip("/")
APP_DIR = Path(__file__).resolve().parent
HUB_LOADED_REVISION = hashlib.sha256(Path(__file__).read_bytes()).hexdigest()
def hub_update_version(data):
match = re.search(rb'appBannerVersion[^>]*>(v[0-9]+)', data)
return match[1].decode('ascii') if match else 'последняя сборка'
def _hub_source_identity():
source = Path(__file__).read_bytes()
return hashlib.sha256(source).hexdigest(), hub_update_version(source)
HUB_LOADED_REVISION, HUB_LOADED_VERSION = _hub_source_identity()
STATIC_DIR = APP_DIR / "static"
BRAND_THEME_COLOR = "#24192f"
FAVICON_ICO_FILE = STATIC_DIR / "favicon.ico"
@@ -5137,8 +5149,8 @@ input,select{{min-width:0;border:1px solid var(--line);border-radius:8px;padding
<div class="brand">
<div class="desktopHeader">
<div class="desktopHeaderTop">
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v118</span></span></h1>
<button class="badge hubUpdateButton" data-hub-update type="button" {'hidden' if not is_owner else ''}>Обновление панели</button>
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v119</span></span></h1>
<button class="badge hubUpdateButton" data-hub-update type="button" {'hidden' if not is_owner else ''}>Проверить обновление панели</button>
<div class="routerSearchDock" id="routerSearchDock">
<button class="routerSearchToggle" id="routerSearchToggle" type="button" aria-expanded="false" aria-controls="routerSearchPanel" data-active="false">
<span>Поиск роутеров</span>
@@ -5475,8 +5487,8 @@ input,select{{min-width:0;border:1px solid var(--line);border-radius:8px;padding
</div>
{vps_resource_widgets_html(mobile=True, resources=vps_resources)}
<div class="mobileSearchDock" id="mobileHubUpdateDock">
<span class="mobileSearchVersion">v118</span>
<button class="badge hubUpdateButton" data-hub-update type="button" {'hidden' if not is_owner else ''}>Обновление панели</button>
<span class="mobileSearchVersion">v119</span>
<button class="badge hubUpdateButton" data-hub-update type="button" {'hidden' if not is_owner else ''}>Проверить обновление панели</button>
</div>
<div class="mobileSearchDock" id="mobileSeasonDock" aria-label="Зимние эффекты">
<button class="routerSearchToggle seasonToggle mobilePanelToggle primary" id="mobileSeasonToggle" type="button" aria-expanded="false" aria-controls="mobileSeasonPanel" data-open="false">
@@ -11784,8 +11796,8 @@ function initHubUpdate() {{
button.disabled = busy || state.checking;
button.dataset.available = state.available ? 'true' : 'false';
button.dataset.updateState = busy ? 'busy' : state.checking ? 'checking' : state.error ? 'error' : state.available ? 'available' : state.checked ? 'current' : 'checking';
button.textContent = busy ? 'Обновляется…' : state.checking ? 'Проверка…' : state.available ? 'Доступно обновление' : 'Обновление панели';
button.title = state.available ? 'Доступна сборка ' + state.remote_version + ' · ' + state.remote_revision.slice(0, 8) : state.error || 'Проверить обновление панели';
button.textContent = busy ? 'Обновляется…' : state.checking ? 'Проверка…' : state.available ? 'Доступно обновление' : state.checked && !state.error ? 'Обновление не требуется' : 'Проверить обновление панели';
button.title = state.available ? 'Доступна сборка ' + state.remote_version + ' · ' + state.remote_revision.slice(0, 8) : state.error || (state.source_older ? 'Установлена ' + state.current_version + '; в источнике ' + state.remote_version + '. Более старая версия не устанавливается.' : 'Проверить обновление панели');
}});
if (busy) {{
if (!pending) {{ remember(job.id); deadline = Date.now() + 300000; }}
@@ -11797,7 +11809,7 @@ function initHubUpdate() {{
}} else if (state.error) message(state.error, 'failed');
else if (job.status === 'failed') message(job.message, 'failed');
else if (state.available) message('Доступно обновление панели: ' + state.remote_version + ' · сборка ' + state.remote_revision.slice(0, 8) + '.');
else if (state.checked && !state.checking) message('У вас последняя версия панели, обновление не требуется.', 'succeeded');
else if (state.checked && !state.checking) message('');
else if (state.checking) message('Проверяется наличие обновлений панели…');
else message('');
}};
@@ -13127,7 +13139,7 @@ button:hover{{filter:brightness(1.06)}}
<form class="login" method="post" action="/login">
{error_html}
<span class="brand">
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v118</span></span></h1>
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v119</span></span></h1>
</span>
<label for="hubUsername">Логин</label>
<input id="hubUsername" name="username" autocomplete="off" autofocus required>
@@ -13599,7 +13611,7 @@ body::after{{content:"";position:fixed;inset:0;pointer-events:none;background:li
<circle cx="65" cy="59" r="3" fill="#E5F2FF"/>
</svg>
</div>
<h2 class="brandTitle">OpenWrt Remote Hub <span class="brandVersion">v118</span></h2>
<h2 class="brandTitle">OpenWrt Remote Hub <span class="brandVersion">v119</span></h2>
</div>
</div>
<div class="brandBottom">
@@ -15416,9 +15428,17 @@ def hub_update_validate(data):
return data
def hub_update_version(data):
match = re.search(rb'appBannerVersion[^>]*>(v[0-9]+)', data)
return match[1].decode('ascii') if match else 'последняя сборка'
def hub_update_older_version(candidate_version, installed_version):
candidate = re.fullmatch(r'v([0-9]+)', candidate_version)
installed = re.fullmatch(r'v([0-9]+)', installed_version)
return bool(candidate and installed and int(candidate[1]) < int(installed[1]))
def hub_update_require_version(data, installed_version):
version = hub_update_version(data)
if hub_update_older_version(version, installed_version):
raise ValueError('В источнике более старая версия ' + version + ', установлена '
+ installed_version + '. Понижение версии через обновление панели запрещено.')
def hub_update_health(url, revision, attempts=30):
@@ -15455,6 +15475,7 @@ def run_hub_update_worker(job_id, directory=None, target=None):
previous = target.read_bytes()
if hashlib.sha256(previous).hexdigest() != job.get('previous_revision'):
raise RuntimeError('Файл Hub изменился после подтверждения; обнови страницу.')
hub_update_require_version(data, hub_update_version(previous))
hub_update_write(directory / 'previous.py', previous, 0o700)
report('installing', 'Устанавливается новая сборка панели…')
hub_update_write(target, data, 0o755)
@@ -15549,10 +15570,12 @@ class HubUpdateManager:
job.update(status='failed', message='Процесс обновления прерван. Итог не подтверждён; проверь сервис owrt-remote на VPS.')
hub_update_state(self.directory, job)
revision = HUB_LOADED_REVISION
source_older = hub_update_older_version(self.remote_version, HUB_LOADED_VERSION)
return {'checking': self.checking, 'error': self.error, 'source': self.source,
'current_revision': revision, 'remote_revision': self.remote_revision,
'current_revision': revision, 'current_version': HUB_LOADED_VERSION,
'remote_revision': self.remote_revision, 'source_older': source_older,
'remote_version': self.remote_version, 'checked': bool(self.checked_at),
'available': bool(self.remote_revision and self.remote_revision != revision),
'available': bool(self.remote_revision and self.remote_revision != revision and not source_older),
'job': job, 'csrf': self.csrf}
def start(self, revision):
@@ -15566,6 +15589,7 @@ class HubUpdateManager:
if revision == HUB_LOADED_REVISION:
raise ValueError('Эта сборка панели уже установлена.')
hub_update_validate(self.candidate)
hub_update_require_version(self.candidate, HUB_LOADED_VERSION)
if shutil.disk_usage(self.target.parent).free < HUB_UPDATE_LIMIT * 3:
raise RuntimeError('Недостаточно свободного места для обновления и резервной копии.')
if shutil.disk_usage(self.directory).free < HUB_UPDATE_LIMIT * 3:
+2 -2
View File
@@ -148,7 +148,7 @@ def prepare():
if changed:
atomic(TARGET, original, 0o755)
restart()
revision = digest(original) if b'HUB_LOADED_REVISION =' in original else ''
revision = digest(original) if b'HUB_LOADED_REVISION' in original else ''
if not healthy(revision):
raise RuntimeError('Previous file restored but service health is not confirmed. Backup: ' + str(ROOT / 'before.py'))
cleanup_test()
@@ -194,7 +194,7 @@ def restore():
raise RuntimeError('Test backup validation failed. Nothing changed.')
atomic(TARGET, original, 0o755)
restart()
revision = digest(original) if b'HUB_LOADED_REVISION =' in original else ''
revision = digest(original) if b'HUB_LOADED_REVISION' in original else ''
if not healthy(revision):
raise RuntimeError('Previous file restored but service health is not confirmed. Backup was kept.')
cleanup_test()