Fossil SCM

fossil-scm / test / standin / transport.sh
Source Blame History 20 lines
f12a09c… danshearer 1 #!/bin/sh
f12a09c… danshearer 2 # Stands in for a server. A test gives it to "fossil sync", "pull" or
f12a09c… danshearer 3 # "push" as the --transport-command, and fossil calls it for each request:
f12a09c… danshearer 4 #
f12a09c… danshearer 5 # transport.sh URL REQUESTFILE REPLYFILE
f12a09c… danshearer 6 #
f12a09c… danshearer 7 # Request N is saved as request.N in the directory $TRANSPORT_DIR and
f12a09c… danshearer 8 # answered with reply.N from there. Where the test wrote no reply.N, the
f12a09c… danshearer 9 # answer is a bare timestamp, which ends the sync. Request 21 fails, so
f12a09c… danshearer 10 # that a client that keeps asking is stopped.
f12a09c… danshearer 11 count=$(cat "$TRANSPORT_DIR/count" 2>/dev/null || echo 0)
f12a09c… danshearer 12 count=$((count + 1))
f12a09c… danshearer 13 echo $count > "$TRANSPORT_DIR/count"
f12a09c… danshearer 14 cp "$2" "$TRANSPORT_DIR/request.$count"
f12a09c… danshearer 15 if test $count -gt 20; then exit 1; fi
f12a09c… danshearer 16 if test -f "$TRANSPORT_DIR/reply.$count"; then
f12a09c… danshearer 17 cp "$TRANSPORT_DIR/reply.$count" "$3"
f12a09c… danshearer 18 else
f12a09c… danshearer 19 printf '# timestamp %s errors 0\n' "$(date -u +%Y-%m-%dT%H:%M:%S)" > "$3"
f12a09c… danshearer 20 fi

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button