lilith-platform.live/deployments/@domains/sansonnet.maison/deploy.sh
2026-05-16 19:26:06 -07:00

60 lines
2.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# =============================================================================
# sansonnet.maison — Deploy Maison Sansonnet brand site (CANONICAL .maison) to vps-0
# =============================================================================
# Source: codebase/@features/sansonnet-web/web/
# Target: quinn-vps:/var/www/sansonnet.maison/
# Defensive maisonsansonnet.com is handled by defensive-coms (301 → sansonnet.maison).
#
# Prerequisites on vps-0:
# 1. DNS A record sansonnet.maison + www.sansonnet.maison → 89.127.233.145
# 2. mkdir -p /var/www/sansonnet.maison
# 3. certbot --nginx -d sansonnet.maison -d www.sansonnet.maison
#
# Flags:
# --nginx Also rsync nginx conf + reload (first-time setup)
# --reload nginx -s reload after rsync
# --dry-run Pass through to rsync
# =============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
SRC="$REPO_ROOT/codebase/@features/sansonnet-web/web"
REMOTE="quinn-vps"
REMOTE_DEST="/var/www/sansonnet.maison"
REMOTE_NGINX_CONF="/etc/nginx/sites-available/sansonnet.maison"
DEPLOY_NGINX=false
RELOAD=false
RSYNC_FLAGS=(-avz --delete)
for arg in "$@"; do
case "$arg" in
--nginx) DEPLOY_NGINX=true ;;
--reload) RELOAD=true ;;
--dry-run) RSYNC_FLAGS+=(--dry-run) ;;
*) echo "Unknown flag: $arg" >&2; exit 2 ;;
esac
done
if [[ ! -d "$SRC" ]]; then
echo "ERROR: source missing: $SRC" >&2; exit 1
fi
echo "[sansonnet.maison] rsync $SRC -> $REMOTE:$REMOTE_DEST"
rsync "${RSYNC_FLAGS[@]}" "$SRC/" "$REMOTE:$REMOTE_DEST/"
if $DEPLOY_NGINX; then
echo "[sansonnet.maison] installing nginx conf"
rsync -avz "$SCRIPT_DIR/nginx/prod.conf" "$REMOTE:$REMOTE_NGINX_CONF"
ssh "$REMOTE" "ln -sf $REMOTE_NGINX_CONF /etc/nginx/sites-enabled/sansonnet.maison && nginx -t && nginx -s reload"
RELOAD=false
fi
if $RELOAD; then
echo "[sansonnet.maison] nginx -s reload on $REMOTE"
ssh "$REMOTE" 'nginx -s reload'
fi
echo "[sansonnet.maison] done."