#!/usr/bin/env bash # Deploys the pushed master to logicate.blax.at (edgerealm) and checks it is live. # Touches only the logigate checkout and container on that shared host. set -euo pipefail HOST=root@static.64.40.140.128.clients.your-server.de DIR=/mnt/HC_Volume_102040804/srv/logigate URL=https://logicate.blax.at cd "$(dirname "$0")/.." if [ -n "$(git status --porcelain)" ]; then echo "Uncommitted changes: commit and push first." >&2 exit 1 fi git fetch -q origin LOCAL=$(git rev-parse HEAD) REMOTE=$(git rev-parse origin/master) if [ "$LOCAL" != "$REMOTE" ]; then echo "HEAD ${LOCAL:0:7} is not origin/master ${REMOTE:0:7}: push (or pull) first." >&2 exit 1 fi echo "==> Deploying ${LOCAL:0:7} to edgerealm" ssh -o BatchMode=yes "$HOST" "cd $DIR && ./deploy.sh" | { grep -E '==> Deployment complete|ERROR|Container logigate Started' || true; } DEPLOYED=$(ssh -o BatchMode=yes "$HOST" "cd $DIR && git rev-parse HEAD") if [ "$DEPLOYED" != "$LOCAL" ]; then echo "Server is on ${DEPLOYED:0:7}, expected ${LOCAL:0:7}." >&2 exit 1 fi # The container needs a moment to start serving. for _ in $(seq 1 20); do PAGE=$(curl -s -o /dev/null -w '%{http_code}' "$URL/" || true) API=$(curl -s -o /dev/null -w '%{http_code}' "$URL/api/auth/me" || true) if [ "$PAGE" = 200 ] && [ "$API" = 200 ]; then echo "Live: $URL at ${LOCAL:0:7}" exit 0 fi sleep 2 done echo "Deployed ${LOCAL:0:7}, but $URL answers page=$PAGE api=$API." >&2 exit 1