#!/usr/bin/env bash
# web/vhost-view -- show exactly what the generator produced
#
# Support conversations get much shorter when the operator can paste the real
# configuration instead of describing it.
set -o pipefail
SELF=$(readlink -f "${BASH_SOURCE[0]}")
NV_BASE=$(cd "$(dirname "$SELF")/../../.." && pwd)
export NV_BASE
# shellcheck source=/dev/null
. "$NV_BASE/lib/core/bootstrap.sh"

ui_header "$(t web_m_vhostview)"

site_pick_domain "${1:-}" || exit $?
domain=$SITE_DOMAIN

vhost=$(site_vhost_path "$domain")
snippet="/etc/nginx/nhanhvps-sites/$domain.conf"

ui_section "$vhost"
if [ -r "$vhost" ]; then sed 's/^/  /' "$vhost"; else ui_info "$(t vhost_missing)"; fi

ui_section "$snippet"
if [ -r "$snippet" ]; then sed 's/^/  /' "$snippet"; else ui_info "$(t vhost_missing)"; fi
ui_blank
exit 0
