← back to Designerssalesreps

deploy-kamatera.sh

37 lines

#!/usr/bin/env bash
# deploy-kamatera.sh — designerssalesreps.com (301 redirect) → Kamatera 45.61.58.125
# This is the typo/plural variant — it redirects everything to designersalesreps.com.
# Usage: bash deploy-kamatera.sh
set -euo pipefail

REMOTE=root@45.61.58.125
LOCAL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REMOTE_DIR=/root/Projects/designerssalesreps
HEALTH_URL=http://127.0.0.1:9916/health

echo "==> Syncing to $REMOTE:$REMOTE_DIR"
rsync -az --delete \
  --exclude='node_modules/' \
  --exclude='.git/' \
  --exclude='.env*' \
  --exclude='*.log' \
  --exclude='logs/' \
  "$LOCAL_DIR/" "$REMOTE:$REMOTE_DIR/"

echo "==> npm install on remote"
ssh "$REMOTE" "cd $REMOTE_DIR && npm install --omit=dev --silent"

echo "==> mkdir logs"
ssh "$REMOTE" "mkdir -p $REMOTE_DIR/logs"

echo "==> pm2 startOrReload"
ssh "$REMOTE" "cd $REMOTE_DIR && pm2 startOrReload ecosystem.config.js --update-env && pm2 save"

echo "==> Health check (origin direct)"
ssh "$REMOTE" "curl -sf $HEALTH_URL" && echo "PASS: origin direct" || { echo "FAIL: health check"; exit 1; }

echo "==> Verifying 301 redirect from CF-proxied variant"
curl -sI https://designerssalesreps.com/ 2>/dev/null | grep -i "location:\|301" || echo "WARN: CF not yet routed (DNS pending?)"

echo "==> Done. designerssalesreps.com 301-redirect is live on :9916"