Push partnership state to the path the partner reads, under both names its page looks for

The scp reused the local absolute path on the remote, so an appdata-mode mirror never received it, and nothing wrote the mirror's own state file at all — a fully onboarded mirror rendered as having no partnership.
This commit is contained in:
Gmer4Lfe
2026-08-17 11:34:54 -04:00
parent fb49eb20e8
commit 587440b6bc
+41 -4
View File
@@ -351,16 +351,53 @@ EOF
) 200>"${file}.lock" ) 200>"${file}.lock"
} }
# Deliver the partnership state to the partner, at the path the partner actually reads, under
# both names its UI looks for.
#
# This used to be one scp to "root@ip:$local_file" — the LOCAL absolute path reused verbatim on
# the remote. That only works while both hosts install to the same place. HOST1 is on flash at
# /boot/config/plugins/varaverk and HOST2 is in appdata mode at /mnt/user/appdata/Varaverk, so
# the copy went to a directory HOST2 does not read and, more often, does not have — and the
# failure surfaced as "will propagate on next sync", which nothing does.
#
# Both names, because the page resolves one file per node: partnership_<that node's hostname>.db.
# The mirror needs partnership_<mirror>.db for its own card and partnership_<owner>.db for the
# owner's. Nothing on the mirror writes the first one during an owner-driven onboard, which is
# why a mirror that was fully onboarded still rendered as having no partnership at all.
# The content is symmetric — state/owner/mirror/onboarded — so one file serves as both.
push_state_to_remote() { push_state_to_remote() {
local local_file="$1" remote_ip="$2" ssh_key="$3" local local_file="$1" remote_ip="$2" ssh_key="$3"
if [[ "$DRY_RUN" == true ]]; then if [[ "$DRY_RUN" == true ]]; then
warn "DRY RUN — would push state file to remote" warn "DRY RUN — would push state file to remote"
return 0 return 0
fi fi
timeout "$SSH_TIMEOUT" scp -i "$ssh_key" -o ConnectTimeout="$SSH_TIMEOUT" -o BatchMode=yes \
"$local_file" "root@${remote_ip}:${local_file}" 2>/dev/null && \ # Resolve where the partner keeps its state, from the partner. varaverk.cfg names its
echo "State file pushed to remote ✅" || \ # SCRIPTS_DIR; absent it, the flash default is the right guess for a stock install.
warn "Could not push state file to remote — will propagate on next sync" local remote_sd remote_state_dir
remote_sd=$(timeout "$SSH_TIMEOUT" ssh -i "$ssh_key" -o ConnectTimeout="$SSH_TIMEOUT" \
-o BatchMode=yes -o StrictHostKeyChecking=no root@"$remote_ip" \
'grep -oP "(?<=SCRIPTS_DIR=\")[^\"]+" /boot/config/plugins/varaverk/varaverk.cfg 2>/dev/null' \
2>/dev/null | tr -d '\r')
[[ -z "$remote_sd" ]] && remote_sd="/boot/config/plugins/varaverk"
remote_state_dir="${remote_sd}/data/state"
local rc=0
local name
for name in "partnership_${REMOTE_SERVER_NAME}.db" "partnership_${LOCAL_SERVER_NAME}.db"; do
timeout "$SSH_TIMEOUT" ssh -i "$ssh_key" -o ConnectTimeout="$SSH_TIMEOUT" \
-o BatchMode=yes -o StrictHostKeyChecking=no root@"$remote_ip" \
"mkdir -p '$remote_state_dir' && cat > '${remote_state_dir}/${name}'" \
< "$local_file" 2>/dev/null || rc=1
done
if [[ $rc -eq 0 ]]; then
echo "State file pushed to $REMOTE_SERVER_NAME:${remote_state_dir}"
return 0
fi
warn "Could not push state to $REMOTE_SERVER_NAME:${remote_state_dir} — it will keep showing"
warn " no partnership until this succeeds. Nothing retries this on a schedule."
return 1
} }
read_remote_state() { read_remote_state() {