← back to Parked Landers

deploy-remote.sh

29 lines

#!/bin/bash
# Runs ON Kamatera. vhost + cert + reload + verify for the 8 parked landers.
set -e
DOMS="protectyourspec.com cannabisofthemonthclub.com hempofthemonthclub.com marijuanaofthemonthclub.com potofthemonthclub.com weedofthemonthclub.com mymemosamples.com hospitalitysalesrepresentatives.com"
for d in $DOMS; do
  root="/var/www/parked-landers/$d"
  [ -f "$root/index.html" ] || { echo "SKIP $d (no index.html uploaded)"; continue; }
  conf="/etc/nginx/sites-available/$d.conf"
  if [ ! -f "$conf" ]; then
    printf 'server {\n    listen 80;\n    listen [::]:80;\n    server_name %s www.%s;\n    root %s;\n    index index.html;\n    location / { try_files $uri $uri/ /index.html; }\n}\n' "$d" "$d" "$root" > "$conf"
    ln -sf "$conf" "/etc/nginx/sites-enabled/$d.conf"
    echo "vhost created: $d"
  else
    echo "vhost exists (left as-is): $d"
  fi
done
nginx -t && systemctl reload nginx
for d in $DOMS; do
  certbot --nginx --non-interactive --agree-tos -m info@designerwallcoverings.com --redirect -d "$d" -d "www.$d" >/dev/null 2>&1 && echo "cert ok: $d" || echo "certbot FAILED: $d (check rate limit / www)"
done
nginx -t && systemctl reload nginx
echo "=== VERIFY (expect 200 + cert=<the domain itself>) ==="
for d in $DOMS; do
  code=$(curl -sSI "https://$d/" -o /dev/null -w "%{http_code}" 2>/dev/null)
  subj=$(echo | openssl s_client -servername "$d" -connect "$d":443 2>/dev/null | openssl x509 -noout -subject 2>/dev/null | sed -E 's/.*CN ?= ?//')
  printf "%-38s %s  cert=%s\n" "$d" "$code" "$subj"
done
echo "=== REMOTE DONE ==="