Files
MeWeb/.gitea/scripts/deploy-server.sh
T
thepraandClaude Opus 5.5 7589121846
Build / Desktop, server and tools (push) Successful in 1m7s
me-web? skeleton: Avalonia 12 app, server, packaging and CI
The first screen (online or not, a Check button, every language with a
draft notice), the desktop and Android heads, the server's /api/info and
/api/ip, a release tool that builds deb, rpm, a Windows exe, macOS zips,
a signed APK and the server, and the Gitea workflows that run it. Rules
adapted from passolo; AGPL-3.0.

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

42 lines
1.0 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)
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