Add opt-in auto-update from Gitea releases
CI / test (push) Successful in 5m57s
Release / release (push) Failing after 19m45s

The program now lives in /usr/local/lib/bamboo and is owned by its service user so it can replace itself.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
VeillaxandClaude Sonnet 5.5 committed 2026-10-26 14:00:42 -06:00
1 parent d87c77dc13
commit 3dc8d1af46
7 files changed
+28 -9

No files matched your search

+10 -6
View File
@@ -5,7 +5,7 @@
# sudo ./install.sh --start the same, then start (or restart) the service
# sudo ./install.sh --uninstall remove the service and binary (keeps the settings and data)
#
# Files: /usr/local/bin/bamboo, /etc/systemd/system/bamboo.service,
# Files: /usr/local/lib/bamboo/bamboo (linked from /usr/local/bin/bamboo), /etc/systemd/system/bamboo.service,
# /etc/bamboo/bamboo.env (your settings and secrets), /var/lib/bamboo (data).
# Set DESTDIR=/some/dir to stage everything there without touching the system.
set -eu
@@ -17,6 +17,7 @@ UNIT=$ROOT/etc/systemd/system/$NAME.service
CONF=$ROOT/etc/$NAME
ENVFILE=$CONF/$NAME.env
DATA=$ROOT/var/lib/$NAME
LIB=$ROOT/usr/local/lib/$NAME # the program lives here, owned by the service, so auto-update can replace it
say() { printf '%s\n' "$*"; }
real() { [ -z "${DESTDIR:-}" ]; } # are we touching the real system?
@@ -30,7 +31,7 @@ if [ "${1:-}" = "--uninstall" ]; then
if real; then
systemctl disable --now "$NAME" > /dev/null 2>&1 || true
fi
rm -f "$UNIT" "$BIN"
rm -f "$UNIT" "$BIN" "$LIB/$NAME"
if real; then
systemctl daemon-reload || true
fi
@@ -46,15 +47,18 @@ if real && ! id "$NAME" > /dev/null 2>&1; then
fi
mkdir -p "$ROOT/usr/local/bin" "$ROOT/etc/systemd/system" "$CONF" "$DATA"
install -m 0755 "$HERE/$NAME" "$BIN.new"
mv -f "$BIN.new" "$BIN" # atomic, so upgrading a running service is safe
mkdir -p "$LIB"
install -m 0755 "$HERE/$NAME" "$LIB/$NAME.new"
mv -f "$LIB/$NAME.new" "$LIB/$NAME" # atomic, so upgrading a running service is safe
rm -f "$BIN"
ln -s "/usr/local/lib/$NAME/$NAME" "$BIN"
install -m 0644 "$HERE/$NAME.service" "$UNIT"
if [ ! -f "$ENVFILE" ]; then
install -m 0600 "$HERE/.env.example" "$ENVFILE"
say "Created $ENVFILE. Edit it before starting."
fi
if real; then
chown -R "$NAME:$NAME" "$DATA"
chown -R "$NAME:$NAME" "$DATA" "$LIB"
fi
if real; then
@@ -66,7 +70,7 @@ if real; then
fi
fi
say "Installed $("$BIN" -version 2> /dev/null || echo "$NAME")."
say "Installed $("$LIB/$NAME" -version 2> /dev/null || echo "$NAME")."
say "Next:"
say " 1. edit $ENVFILE"
say " 2. systemctl start $NAME (or run this again with --start)"