From f5c8e31d26fbb56ea4ee2155f7aeaa9c3a4446f9 Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Thu, 1 Oct 2026 03:32:02 -0700 Subject: [PATCH] fix(forgejo): install the pinned release by renaming over the running binary (#136) setup.sh downloaded straight to /usr/local/bin/forgejo while forgejo.service was running, which fails with ETXTBSY ("Text file busy"). Every deploy logged "forgejo download failed" and prod stayed on 11.0.1 although the pin is 11.0.15. Download to forgejo.new, check its --version, and rename it over the old binary; the existing `systemctl restart forgejo` then starts the new one. A failed or wrong download now keeps the installed binary instead of warning that the backend will be unavailable. Co-authored-by: Claude Opus 5.5 (1M context) --- setup.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index 1bb4c20..10e1bc0 100755 --- a/setup.sh +++ b/setup.sh @@ -1104,9 +1104,21 @@ if [ "$FORGEJO" = "1" ]; then esac if [ -n "$FJ_ARCH" ]; then log "downloading forgejo ${FORGEJO_VERSION} (${FJ_ARCH})" - curl -fsSL "https://codeberg.org/forgejo/forgejo/releases/download/v${FORGEJO_VERSION}/forgejo-${FORGEJO_VERSION}-linux-${FJ_ARCH}" \ - -o /usr/local/bin/forgejo && chmod 0755 /usr/local/bin/forgejo \ - || warn "forgejo download failed — backend will be unavailable" + # Download beside the binary and rename over it. Writing straight to + # /usr/local/bin/forgejo while forgejo.service runs fails with ETXTBSY + # ("Text file busy"), which left prod pinned to an old release with a + # "download failed" warning on every redeploy. A rename is atomic and + # legal on a running executable; the old inode lives until the restart. + if curl -fsSL "https://codeberg.org/forgejo/forgejo/releases/download/v${FORGEJO_VERSION}/forgejo-${FORGEJO_VERSION}-linux-${FJ_ARCH}" \ + -o /usr/local/bin/forgejo.new \ + && chmod 0755 /usr/local/bin/forgejo.new \ + && /usr/local/bin/forgejo.new --version 2>/dev/null | grep -q "$FORGEJO_VERSION"; then + mv -f /usr/local/bin/forgejo.new /usr/local/bin/forgejo + log "forgejo ${FORGEJO_VERSION} installed" + else + rm -f /usr/local/bin/forgejo.new + warn "forgejo ${FORGEJO_VERSION} download failed — keeping the installed binary" + fi fi fi