Files
smom-dbis-138/scripts/deployment/deploy-z-domains.sh

42 lines
1.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Install nginx vhost for Z Ecosystem (zblockchainsystem.com)
set -euo pipefail
REPO_DIR="${Z_ECOSYSTEM_ROOT:-${OMNL_BANK_ROOT:-$HOME/smom-dbis-138}}"
VHOST_SRC="$REPO_DIR/deploy/nginx/z-ecosystem-domains.conf"
VHOST_DST="/etc/nginx/sites-available/z-ecosystem-domains"
VHOST_LINK="/etc/nginx/sites-enabled/z-ecosystem-domains"
log() { echo "[$(date -Iseconds)] $*"; }
if [ ! -f "$VHOST_SRC" ]; then
echo "Missing $VHOST_SRC" >&2
exit 1
fi
log "Installing Z Ecosystem nginx vhost..."
sudo cp "$VHOST_SRC" "$VHOST_DST"
SNIPPET_SRC="$REPO_DIR/deploy/nginx/z-ecosystem-common-locations.conf"
SNIPPET_DST="/etc/nginx/snippets/z-ecosystem-common-locations.conf"
sudo cp "$SNIPPET_SRC" "$SNIPPET_DST"
sudo ln -sf "$VHOST_DST" "$VHOST_LINK"
log "Testing nginx..."
sudo nginx -t
log "Reloading nginx..."
sudo systemctl reload nginx
check_host() {
local host="$1"
local expect="$2"
local code
code=$(curl -s -o /dev/null -w '%{http_code}' -H "Host: $host" "http://127.0.0.1/")
log " $host -> HTTP $code (expect redirect toward $expect)"
}
check_host zblockchainsystem.com /z
check_host www.zblockchainsystem.com /z
log "Z domain deploy complete — https://zblockchainsystem.com/z"