Commit 8c7024c0f4

8c7024c0f47d6bedd901d5e04a3a0294d8f5f775

parent: 3bce3374cf

Verified · cmc ci/build: success ci/test: failure ci/vuln: success

cmc <hello@cleberg.net> · 2026-09-02 04:32 UTC

deploy: one copy helper, so neither target assumes rsync

make deploy-runner called rsync outright and failed on bay1, which has
none; install.sh had the scp fallback and the runner target did not.

deploy/copy.sh holds the choice once: rsync --partial --inplace -z when
the host has it, scp -C otherwise. install.sh and both copies in
deploy-runner go through it.

Layout: unified · split

Makefile +2 −2
@@ -71,9 +71,9 @@ deploy-runner: preflight
71 @echo "==> building $(RUNNER_BIN)" 71 @echo "==> building $(RUNNER_BIN)"
72 $(CROSS) go build -trimpath -ldflags='$(LDFLAGS)' -o $(RUNNER_BIN) ./cmd/gitbay-runner 72 $(CROSS) go build -trimpath -ldflags='$(LDFLAGS)' -o $(RUNNER_BIN) ./cmd/gitbay-runner
73 @echo "==> pushing runner to $(HOST)" 73 @echo "==> pushing runner to $(HOST)"
74 rsync --partial --inplace -z -e "ssh -p $(PORT)" $(RUNNER_BIN) root@$(HOST):/usr/local/bin/gitbay-runner.new 74 ./deploy/copy.sh $(HOST) $(PORT) $(RUNNER_BIN) /usr/local/bin/gitbay-runner.new
75 ssh -p $(PORT) root@$(HOST) 'mkdir -p /etc/systemd/system/gitbay-runner.service.d' 75 ssh -p $(PORT) root@$(HOST) 'mkdir -p /etc/systemd/system/gitbay-runner.service.d'
76 rsync -z -e "ssh -p $(PORT)" deploy/gitbay-runner.override.conf root@$(HOST):/etc/systemd/system/gitbay-runner.service.d/override.conf 76 ./deploy/copy.sh $(HOST) $(PORT) deploy/gitbay-runner.override.conf /etc/systemd/system/gitbay-runner.service.d/override.conf
77 ssh -p $(PORT) root@$(HOST) 'set -eu; \ 77 ssh -p $(PORT) root@$(HOST) 'set -eu; \
78 chmod 755 /usr/local/bin/gitbay-runner.new; \ 78 chmod 755 /usr/local/bin/gitbay-runner.new; \
79 mv /usr/local/bin/gitbay-runner.new /usr/local/bin/gitbay-runner; \ 79 mv /usr/local/bin/gitbay-runner.new /usr/local/bin/gitbay-runner; \
deploy/copy.sh added +14
@@ -0,0 +1,14 @@
1#!/bin/sh
2# Copy one file to the host: rsync when the host has it, since a stalled
3# transfer then resumes and the bytes are compressed on the wire; scp -C
4# otherwise. Both deploy targets go through here so neither can assume a
5# tool the host lacks.
6#
7# deploy/copy.sh <host> <port> <local-file> <remote-path>
8set -eu
9host=$1 port=$2 src=$3 dst=$4
10if ssh -p "$port" "root@$host" 'command -v rsync >/dev/null 2>&1'; then
11 rsync --partial --inplace -z -e "ssh -p $port" "$src" "root@$host:$dst"
12else
13 scp -C -P "$port" "$src" "root@$host:$dst"
14fi
deploy/install.sh +1 −7
@@ -8,13 +8,7 @@ bin=dist/gitbayd-linux-amd64
8 8
9[ -f "$bin" ] || { echo "build first: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $bin ./cmd/gitbayd" >&2; exit 1; } 9[ -f "$bin" ] || { echo "build first: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $bin ./cmd/gitbayd" >&2; exit 1; }
10 10
11# rsync resumes a transfer the host's load stalled and compresses the 11"$(dirname "$0")/copy.sh" "$host" "$port" "$bin" /usr/local/bin/gitbayd.new
12# binary on the wire; scp -C is the fallback where the host has no rsync.
13if ssh -p "$port" "root@$host" 'command -v rsync >/dev/null'; then
14 rsync --partial --inplace -z -e "ssh -p $port" "$bin" "root@$host:/usr/local/bin/gitbayd.new"
15else
16 scp -C -P "$port" "$bin" "root@$host:/usr/local/bin/gitbayd.new"
17fi
18ssh -p "$port" "root@$host" ' 12ssh -p "$port" "root@$host" '
19 set -eu 13 set -eu
20 chmod 755 /usr/local/bin/gitbayd.new 14 chmod 755 /usr/local/bin/gitbayd.new