Release v115 with router global logs and mobile header layout
This commit is contained in:
1 parent
0508438de0
commit
4ceb3d031a
39 files changed
+1181
-93
No files matched your search
@@ -0,0 +1,192 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string]$Router,
|
||||
[ValidateSet('Install', 'Rollback')][string]$Action = 'Install',
|
||||
[switch]$PrepareOnly
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$RepoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$UploadName = 'owrt-global-logs-' + [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__
|
||||
backup=/root/owrt-remote-backup-before-global-logs-v115
|
||||
items='cgi agent init logs.sh logs-init luci'
|
||||
changed=0
|
||||
phase=preflight
|
||||
item_path() {
|
||||
case "$1" in
|
||||
cgi) echo /www/cgi-bin/owrt-remote ;;
|
||||
agent) echo /usr/sbin/owrt-remote ;;
|
||||
init) echo /etc/init.d/owrt-remote ;;
|
||||
logs.sh) echo /usr/lib/owrt-remote/logs.sh ;;
|
||||
logs-init) echo /etc/init.d/owrt-remote-logs ;;
|
||||
luci) echo /www/luci-static/resources/view/owrt_remote.js ;;
|
||||
esac
|
||||
}
|
||||
refresh_router_ui() {
|
||||
rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
|
||||
if [ -x /etc/init.d/rpcd ]; then /etc/init.d/rpcd restart || true; fi
|
||||
if [ -x /etc/init.d/uhttpd ]; then /etc/init.d/uhttpd reload || true; fi
|
||||
}
|
||||
save_files() {
|
||||
local dir item path
|
||||
dir=$1
|
||||
mkdir -p "$dir"
|
||||
chmod 700 "$dir"
|
||||
for item in $items; do
|
||||
path=$(item_path "$item")
|
||||
if [ -e "$path" ]; then cp -p "$path" "$dir/$item"; else : >"$dir/$item.absent"; fi
|
||||
done
|
||||
if [ -x /etc/init.d/owrt-remote-logs ] && /etc/init.d/owrt-remote-logs enabled; then : >"$dir/logs-enabled"; fi
|
||||
if ubus call service list '{"name":"owrt-remote-logs"}' 2>/dev/null | grep -q '"running": true'; then : >"$dir/logs-running"; fi
|
||||
if /usr/sbin/owrt-remote status 2>/dev/null | grep -q '^xray_state: running'; then : >"$dir/tunnel-running"; fi
|
||||
: >"$dir/complete"
|
||||
}
|
||||
validate_backup() {
|
||||
local dir item
|
||||
dir=$1
|
||||
[ -f "$dir/complete" ] || return 1
|
||||
for item in $items; do
|
||||
[ -s "$dir/$item" ] || [ -f "$dir/$item.absent" ] || return 1
|
||||
done
|
||||
}
|
||||
restore_files() {
|
||||
local dir item path
|
||||
dir=$1
|
||||
validate_backup "$dir" || { echo "Incomplete backup: $dir" >&2; return 1; }
|
||||
if [ -x /etc/init.d/owrt-remote-logs ]; then
|
||||
/etc/init.d/owrt-remote-logs stop || true
|
||||
/etc/init.d/owrt-remote-logs disable || true
|
||||
fi
|
||||
for item in $items; do
|
||||
path=$(item_path "$item")
|
||||
if [ -f "$dir/$item.absent" ]; then
|
||||
rm -f "$path" || return 1
|
||||
else
|
||||
cp -p "$dir/$item" "$path" || return 1
|
||||
fi
|
||||
done
|
||||
if [ -x /etc/init.d/owrt-remote-logs ]; then
|
||||
[ ! -f "$dir/logs-enabled" ] || /etc/init.d/owrt-remote-logs enable
|
||||
[ ! -f "$dir/logs-running" ] || /etc/init.d/owrt-remote-logs start
|
||||
else
|
||||
rm -rf /tmp/owrt-remote-logs
|
||||
fi
|
||||
if [ -f "$stage/previous/tunnel-running" ]; then /etc/init.d/owrt-remote restart; fi
|
||||
refresh_router_ui
|
||||
}
|
||||
cleanup() {
|
||||
code=$?
|
||||
trap - EXIT
|
||||
if [ "$code" -ne 0 ]; then
|
||||
printf 'Failed during %s (rc=%s).\n' "$phase" "$code" >&2
|
||||
if [ "$changed" = 1 ]; then
|
||||
echo 'Restoring files from this attempt.' >&2
|
||||
restore_files "$stage/previous" || echo 'Restore failed; retained backup is available.' >&2
|
||||
fi
|
||||
fi
|
||||
for item in $items; do path=$(item_path "$item"); rm -f "$path.new-__UPLOAD_NAME__"; done
|
||||
rm -rf "$stage"
|
||||
exit "$code"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
for item in cgi agent init; do path=$(item_path "$item"); test -s "$path"; done
|
||||
if [ '__ACTION__' = Install ]; then
|
||||
for item in $items; do test -s "$stage/$item"; done
|
||||
for item in cgi agent init logs.sh logs-init; do sh -n "$stage/$item"; done
|
||||
command -v logread >/dev/null
|
||||
command -v ubus >/dev/null
|
||||
command -v mkfifo >/dev/null
|
||||
grep -F -q 'globalLogsToggle' "$stage/cgi"
|
||||
for item in cgi luci; do grep -F -q 'v115' "$stage/$item"; done
|
||||
grep -F -q 'LOG_KEEP_SECONDS=86400' "$stage/logs.sh"
|
||||
phase=backup
|
||||
if [ ! -e "$backup" ]; then save_files "$stage/retained"; mv "$stage/retained" "$backup"; fi
|
||||
validate_backup "$backup" || { echo "Incomplete backup: $backup. Nothing changed." >&2; exit 1; }
|
||||
save_files "$stage/previous"
|
||||
phase=install
|
||||
changed=1
|
||||
if [ -x /etc/init.d/owrt-remote-logs ]; then /etc/init.d/owrt-remote-logs stop; fi
|
||||
mkdir -p /usr/lib/owrt-remote /www/luci-static/resources/view
|
||||
for item in $items; do
|
||||
path=$(item_path "$item")
|
||||
cp "$stage/$item" "$path.new-__UPLOAD_NAME__"
|
||||
case "$item" in logs.sh|luci) chmod 644 "$path.new-__UPLOAD_NAME__" ;; *) chmod 755 "$path.new-__UPLOAD_NAME__" ;; esac
|
||||
mv -f "$path.new-__UPLOAD_NAME__" "$path"
|
||||
done
|
||||
/etc/init.d/owrt-remote-logs enable
|
||||
/etc/init.d/owrt-remote-logs start
|
||||
phase=verify
|
||||
ready=0
|
||||
for attempt in 1 2 3 4 5; do
|
||||
if ubus call service list '{"name":"owrt-remote-logs"}' | grep -q '"running": true'; then ready=1; break; fi
|
||||
sleep 1
|
||||
done
|
||||
if [ "$ready" != 1 ]; then echo 'Log collector did not start.' >&2; logread -e owrt-remote | tail -n 30 >&2; exit 1; fi
|
||||
marker='Глобал логи: collector-__UPLOAD_NAME__'
|
||||
ready=0
|
||||
for attempt in 1 2 3 4 5; do
|
||||
logger -t owrt-remote "$marker"
|
||||
sleep 1
|
||||
if sh /usr/lib/owrt-remote/logs.sh read | grep -F -q "$marker"; then ready=1; break; fi
|
||||
done
|
||||
if [ "$ready" != 1 ]; then echo 'Log collector is running but did not capture the test event.' >&2; exit 1; fi
|
||||
for item in $items; do path=$(item_path "$item"); cmp "$stage/$item" "$path"; done
|
||||
if [ -f "$stage/previous/tunnel-running" ]; then
|
||||
phase=tunnel-restart
|
||||
/etc/init.d/owrt-remote restart
|
||||
ready=0
|
||||
for attempt in 1 2 3 4 5 6 7 8 9 10; do
|
||||
if /usr/sbin/owrt-remote status | grep -q '^xray_state: running'; then ready=1; break; fi
|
||||
sleep 1
|
||||
done
|
||||
if [ "$ready" != 1 ]; then echo 'Tunnel did not restart.' >&2; logread -e owrt-remote | tail -n 30 >&2; exit 1; fi
|
||||
fi
|
||||
refresh_router_ui
|
||||
echo 'Log collector: running. Router settings preserved.'
|
||||
else
|
||||
validate_backup "$backup" || { echo "No complete backup: $backup. Nothing changed." >&2; exit 1; }
|
||||
save_files "$stage/previous"
|
||||
changed=1
|
||||
phase=rollback
|
||||
restore_files "$backup"
|
||||
fi
|
||||
printf 'Backup: %s\n' "$backup"
|
||||
printf '\nGLOBAL_LOGS_ROUTER_%s_OK\n' '__ACTION__'
|
||||
'@
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
$Files = @{
|
||||
'cgi' = 'files\www\cgi-bin\owrt-remote'
|
||||
'agent' = 'files\usr\sbin\owrt-remote'
|
||||
'init' = 'files\etc\init.d\owrt-remote'
|
||||
'logs.sh' = 'files\usr\lib\owrt-remote\logs.sh'
|
||||
'logs-init' = 'files\etc\init.d\owrt-remote-logs'
|
||||
'luci' = 'files\www\luci-static\resources\view\owrt_remote.js'
|
||||
}
|
||||
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') {
|
||||
foreach ($Item in $Files.GetEnumerator()) {
|
||||
$Content = [System.IO.File]::ReadAllText((Join-Path $RepoRoot $Item.Value)).Replace("`r`n", "`n")
|
||||
[System.IO.File]::WriteAllText((Join-Path $StageRoot $Item.Key), $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 "Global logs $Action finished successfully. Refresh the router panel with Ctrl+F5."
|
||||
} 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 }
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup=/root/owrt-remote-backup-before-heartbeat-redirect-v114
|
||||
backup=/root/owrt-remote-backup-before-heartbeat-redirect-v115
|
||||
agent=/usr/sbin/owrt-remote
|
||||
wan=/usr/lib/owrt-remote/wan.sh
|
||||
changed=0
|
||||
|
||||
@@ -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-v114',
|
||||
[ValidatePattern('^[a-zA-Z0-9_-]+$')][string]$BackupName = 'host-policy-v115',
|
||||
[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 'v114' "$stage/$item"; done
|
||||
for item in cgi luci; do grep -F -q 'v115' "$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 'v114' /www/cgi-bin/owrt-remote
|
||||
grep -F -q 'v114' /www/luci-static/resources/view/owrt_remote.js
|
||||
echo HOST_POLICY_ROUTER_V114_OK
|
||||
grep -F -q 'v115' /www/cgi-bin/owrt-remote
|
||||
grep -F -q 'v115' /www/luci-static/resources/view/owrt_remote.js
|
||||
echo HOST_POLICY_ROUTER_V115_OK
|
||||
else
|
||||
test -f "$backup/complete"
|
||||
save_files "$stage/previous"
|
||||
changed=1
|
||||
restore_files "$backup"
|
||||
/usr/sbin/owrt-remote status
|
||||
echo HOST_POLICY_ROUTER_V114_ROLLBACK_OK
|
||||
echo HOST_POLICY_ROUTER_V115_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-v114
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-host-policy-v115
|
||||
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 'v114' "$stage/hub.py"
|
||||
grep -F -q 'v115' "$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_V114_%s_OK\n' '__ACTION__'
|
||||
printf '\nHOST_POLICY_VPS_V115_%s_OK\n' '__ACTION__'
|
||||
'@
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ if ($Target -eq 'Router') {
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup=/root/owrt-remote-backup-before-hub-url-v114
|
||||
backup=/root/owrt-remote-backup-before-hub-url-v115
|
||||
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 'v114' "$stage/$item"; done
|
||||
for item in cgi luci; do grep -F -q 'v115' "$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_V114_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nHUB_URL_ROUTER_V115_%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-v114
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-url-v115
|
||||
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 'v114' "$stage/hub.py"
|
||||
grep -F -q 'v115' "$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_V114_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nHUB_URL_VPS_V115_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
}
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action).Replace('__HUB_URL__', $HubUrl)
|
||||
|
||||
@@ -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-v114
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-online-status-v115
|
||||
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_V114_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nONLINE_STATUS_V115_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
try {
|
||||
|
||||
@@ -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-v114
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-password-logout-v115
|
||||
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_V114_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nPASSWORD_LOGOUT_V115_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -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-v114
|
||||
captcha_backup=/opt/owrt-remote/captcha-before-recaptcha-v3-v114.json
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-recaptcha-v3-v115
|
||||
captcha_backup=/opt/owrt-remote/captcha-before-recaptcha-v3-v115.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 'v114' in source
|
||||
assert 'v115' 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_V114_OK
|
||||
echo RECAPTCHA_V3_V115_OK
|
||||
'@
|
||||
} elseif ($Action -eq 'Rollback') {
|
||||
$RemoteScript = @'
|
||||
@@ -96,8 +96,8 @@ echo RECAPTCHA_V3_V114_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-v114
|
||||
captcha_backup=/opt/owrt-remote/captcha-before-recaptcha-v3-v114.json
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-recaptcha-v3-v115
|
||||
captcha_backup=/opt/owrt-remote/captcha-before-recaptcha-v3-v115.json
|
||||
candidate=$target.rollback-__UPLOAD_NAME__
|
||||
changed=0
|
||||
restore_captcha() {
|
||||
|
||||
@@ -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-v114
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-resource-fix-v115
|
||||
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 'v114' in source
|
||||
assert 'v115' 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_V114_OK
|
||||
echo RESOURCE_FIX_V115_OK
|
||||
'@
|
||||
} elseif ($Action -eq 'Rollback') {
|
||||
$RemoteScript = @'
|
||||
@@ -86,7 +86,7 @@ echo RESOURCE_FIX_V114_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-v114
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-resource-fix-v115
|
||||
candidate=$target.rollback-__UPLOAD_NAME__
|
||||
changed=0
|
||||
cleanup() {
|
||||
|
||||
@@ -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-v114
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-router-card-ui-v115
|
||||
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_V114_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nROUTER_CARD_UI_V115_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string]$Vps,
|
||||
[ValidateSet('Install', 'Rollback')][string]$Action = 'Install',
|
||||
[switch]$PrepareOnly
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$RepoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$UploadName = 'owrt-version-v115-' + [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-v115
|
||||
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 = ('v115',)
|
||||
if 'v' + '114' 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]
|
||||
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
|
||||
|
||||
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 && curl -fsS --max-time 5 http://127.0.0.1:8088/health; then
|
||||
healthy=1
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
if [ "$healthy" -ne 1 ]; then
|
||||
echo 'Health check did not become ready.' >&2
|
||||
show_failure
|
||||
exit 1
|
||||
fi
|
||||
cmp "$source_file" "$target"
|
||||
printf '\nBackup: %s\nHUB_V115_%s_OK\n' "$backup" '__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 '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 "Hub v115 $Action finished successfully. Refresh the Hub panel."
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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-v114
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-vps-widgets-v115
|
||||
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 'v114' "$stage/hub.py"
|
||||
grep -F -q 'v115' "$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_V114_%s_OK\n' '__ACTION__'
|
||||
printf '\nVPS_WIDGETS_V115_%s_OK\n' '__ACTION__'
|
||||
'@
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
try {
|
||||
|
||||
@@ -20,7 +20,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup=/root/owrt-remote-backup-before-wan-multi-v114
|
||||
backup=/root/owrt-remote-backup-before-wan-multi-v115
|
||||
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 'v114' "$stage/$item"; done
|
||||
for item in cgi luci; do grep -F -q 'v115' "$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"
|
||||
|
||||
@@ -17,7 +17,7 @@ $RemoteScript = @'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
stage=/tmp/__UPLOAD_NAME__
|
||||
backup=/root/owrt-remote-backup-before-wan-stability-v114
|
||||
backup=/root/owrt-remote-backup-before-wan-stability-v115
|
||||
config=/etc/config/owrtremote
|
||||
changed=0
|
||||
fail() {
|
||||
|
||||
@@ -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-v114
|
||||
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-web-push-v115
|
||||
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_V114_%s_OK\n' "$backup" '__ACTION__'
|
||||
printf '\nBackup: %s\nWEB_PUSH_V115_%s_OK\n' "$backup" '__ACTION__'
|
||||
'@
|
||||
|
||||
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||
|
||||
@@ -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-v114
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-apply-v115
|
||||
backup=$backup_dir/owrt-remote
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -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-v114
|
||||
backup_dir=/root/owrt-remote-backup-before-xray-mobile-v115
|
||||
backup=$backup_dir/owrt-remote
|
||||
candidate=$target.new-__UPLOAD_NAME__
|
||||
changed=0
|
||||
|
||||
@@ -4861,7 +4861,7 @@ 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">v114</span></span></h1>
|
||||
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v115</span></span></h1>
|
||||
<div class="routerSearchDock" id="routerSearchDock">
|
||||
<button class="routerSearchToggle" id="routerSearchToggle" type="button" aria-expanded="false" aria-controls="routerSearchPanel" data-active="false">
|
||||
<span>Поиск роутеров</span>
|
||||
@@ -5214,7 +5214,7 @@ systemctl restart owrt-remote-xray</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mobileSearchDock" id="mobileRouterSearchDock">
|
||||
<span class="mobileSearchVersion">v114</span>
|
||||
<span class="mobileSearchVersion">v115</span>
|
||||
<button class="routerSearchToggle mobilePanelToggle primary" id="mobileRouterSearchToggle" type="button" aria-expanded="false" aria-controls="mobileRouterSearchPanel" data-active="false">
|
||||
<span>Поиск роутеров</span>
|
||||
</button>
|
||||
@@ -12578,7 +12578,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">v114</span></span></h1>
|
||||
<h1 class="appBanner"><span>OpenWrt Remote Hub <span class="appBannerVersion">v115</span></span></h1>
|
||||
</span>
|
||||
<label for="hubUsername">Логин</label>
|
||||
<input id="hubUsername" name="username" autocomplete="off" autofocus required>
|
||||
@@ -13050,7 +13050,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">v114</span></h2>
|
||||
<h2 class="brandTitle">OpenWrt Remote Hub <span class="brandVersion">v115</span></h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="brandBottom">
|
||||
|
||||
Reference in new issue
Block a user