donation item, shop soft open
All checks were successful
Deploy / build-deploy (push) Successful in 4m11s

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-08-17 11:04:03 +02:00
commit abbd616b40
23 changed files with 2898 additions and 209 deletions

View file

@ -66,7 +66,26 @@ done
[ -n "$FILES" ] || { echo "publish-media: no input file. See --help." >&2; exit 1; }
WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT
# One SSH connection for the whole run, not one per operation. The origin runs
# `ufw limit 22/tcp`, which rejects the sixth new connection from a source inside
# 30 s — and a video publishes three artifacts at three connections each (probe,
# copy, rename), so a run used to trip the limit on the poster's rename and die
# with the H.264 fallback still unsent. The failure does not even look like rate
# limiting: ufw REJECTs with ICMP port-unreachable, ssh moves on to the AAAA
# record, and reports the errno of the last address it tried — so a refused IPv4
# connection surfaces as "Network is unreachable" from a host with no IPv6 route.
# Multiplexing over one master socket keeps a run at a single connection however
# many artifacts it produces, and leaves the limit in place doing its real job.
SSH_CTL="$WORK/cm"
SSH_OPTS="-o BatchMode=yes -o ControlMaster=auto -o ControlPath=$SSH_CTL -o ControlPersist=60"
cleanup() {
if [ -S "$SSH_CTL" ]; then
ssh -O exit $SSH_OPTS "$MEDIA_HOST" >/dev/null 2>&1 || true
fi
rm -rf "$WORK"
}
trap cleanup EXIT
# Upload only what is not already there. The name is the content hash, so a name
# that exists on the mount holds these exact bytes and re-sending them would
@ -75,14 +94,14 @@ trap 'rm -rf "$WORK"' EXIT
publish_file() {
local_file=$1
remote_name=$2
if ssh -o BatchMode=yes "$MEDIA_HOST" "test -f '$MEDIA_PATH/$remote_name'"; then
if ssh $SSH_OPTS "$MEDIA_HOST" "test -f '$MEDIA_PATH/$remote_name'"; then
echo " already published: $remote_name"
return 0
fi
# Land it under a temporary name and move it into place, so a reader can
# never see a partial file under the name its hash promises.
scp -q -o BatchMode=yes "$local_file" "$MEDIA_HOST:$MEDIA_PATH/.$remote_name.part"
ssh -o BatchMode=yes "$MEDIA_HOST" \
scp -q $SSH_OPTS "$local_file" "$MEDIA_HOST:$MEDIA_PATH/.$remote_name.part"
ssh $SSH_OPTS "$MEDIA_HOST" \
"chmod 0644 '$MEDIA_PATH/.$remote_name.part' && \
mv -f '$MEDIA_PATH/.$remote_name.part' '$MEDIA_PATH/$remote_name'"
echo " uploaded: $remote_name"