mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
Brought up to date with the private repository (a06d3c5)
This commit is contained in:
commit
eda992fcff
144 files changed
+31026
No files matched your search
@@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=Update the Burrow server from GitHub
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash /home/aj/ajc-private-server/deploy/update.sh
|
||||
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Look for a new Burrow server every two minutes
|
||||
|
||||
[Timer]
|
||||
OnBootSec=2min
|
||||
OnUnitActiveSec=2min
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# brings the server to origin's main and restarts it when the change needs it.
|
||||
# run as root by burrow-update.timer; git itself runs as the server's user.
|
||||
set -euo pipefail
|
||||
|
||||
dir=${BURROW_DIR:-/home/aj/ajc-private-server}
|
||||
user=${BURROW_USER:-aj}
|
||||
service=${BURROW_SERVICE:-burrow}
|
||||
branch=${BURROW_BRANCH:-main}
|
||||
|
||||
git() { runuser -u "$user" -- git -C "$dir" "$@"; }
|
||||
|
||||
git fetch --quiet origin "$branch"
|
||||
old=$(git rev-parse HEAD)
|
||||
new=$(git rev-parse "origin/$branch")
|
||||
[ "$old" != "$new" ] || exit 0
|
||||
|
||||
# only a fast-forward: a server that was edited by hand is left for a person
|
||||
git merge --quiet --ff-only "origin/$branch"
|
||||
|
||||
# a file that does not parse would take the game down on restart
|
||||
for file in $(git diff --name-only "$old" "$new" -- '*.js'); do
|
||||
if [ -f "$dir/$file" ] && ! runuser -u "$user" -- node --check "$dir/$file"; then
|
||||
git reset --quiet --hard "$old"
|
||||
echo "update to $new refused: $file does not parse; staying on $old" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# public/ is read from disk on every request; the rest is loaded once, at start
|
||||
if git diff --name-only "$old" "$new" | grep -qvE '^(public/|client-updates/|test/|tools/|deploy/|[^/]+\.md$|\.gitignore$)'; then
|
||||
systemctl restart "$service"
|
||||
echo "updated $old -> $new, restarted $service"
|
||||
else
|
||||
echo "updated $old -> $new, no restart needed"
|
||||
fi
|
||||
Reference in new issue
Block a user