Files
MeWeb/.gitea/scripts/deploy-server.sh
T
thepraandClaude Opus 5.5 16a1cecaae
Build / Desktop, server and tools (push) Successful in 29s
The deployed folder keeps 755: mktemp's 700 was copied onto it
rsync -a carried the staging folder's mode to /var/www/meweb.arasaka.software,
and the meweb user could no longer enter it (status=200/CHDIR).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012CzABvBkbcFqoHdmi8b9WB
2026-10-15 01:32:32 +02:00

43 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
set -eu
archive=$1
app=/var/www/meweb.arasaka.software
backups=/var/backups/meweb.arasaka.software
health=http://127.0.0.1:5480/api/info
stamp=$(date -u +%Y%m%d%H%M%S)
stage=$(mktemp -d)
chmod 755 "$stage"
trap 'rm -rf "$stage"' EXIT
tar -xzf "$archive" -C "$stage"
test -x "$stage/MeWeb.Server"
snapshot=""
if [ -x "$app/MeWeb.Server" ]; then
snapshot="$backups/meweb-$stamp"
rsync -a "$app/" "$snapshot/"
ls -1dt "$backups"/meweb-* 2>/dev/null | tail -n +4 | xargs -r rm -rf
fi
sudo systemctl stop meweb || true
rsync -a --delete "$stage/" "$app/"
sudo systemctl start meweb
for attempt in $(seq 1 30); do
if curl -fsS "$health" | grep -q "\"commit\":\"$COMMIT\""; then
echo "deployed $COMMIT: $(curl -fsS "$health")"
exit 0
fi
sleep 1
done
echo "::error::the new server did not answer with commit $COMMIT"
sudo systemctl status meweb --no-pager | tail -20 || true
if [ -n "$snapshot" ]; then
sudo systemctl stop meweb || true
rsync -a --delete "$snapshot/" "$app/"
sudo systemctl start meweb
echo "rolled back to $snapshot"
fi
exit 1