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
7171 @echo "==> building $(RUNNER_BIN)"
7272 $(CROSS) go build -trimpath -ldflags='$(LDFLAGS)' -o $(RUNNER_BIN) ./cmd/gitbay-runner
7373 @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
7575 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
7777 ssh -p $(PORT) root@$(HOST) 'set -eu; \
7878 chmod 755 /usr/local/bin/gitbay-runner.new; \
7979 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
88
99[ -f "$bin" ] || { echo "build first: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $bin ./cmd/gitbayd" >&2; exit 1; }
1010
11# rsync resumes a transfer the host's load stalled and compresses the
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
11"$(dirname "$0")/copy.sh" "$host" "$port" "$bin" /usr/local/bin/gitbayd.new
1812ssh -p "$port" "root@$host" '
1913 set -eu
2014 chmod 755 /usr/local/bin/gitbayd.new