Align LXC deploy with BIT-465: write-version-json.sh, optional webhook-deploy.sh, verify.sh fails when ER_VERSION_JSON_PATH is set but missing/invalid, env.example + nginx sketch + runbook updates. Ignore deploy/lxc/runtime/ (generated on server).
79 lines
2.5 KiB
Bash
Executable File
79 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Smoke checks after install: MariaDB reachability (optional) + ingest /health.
|
|
set -euo pipefail
|
|
|
|
_ENV_FILE="/etc/error-reporting/env"
|
|
if [[ -f "${_ENV_FILE}" ]]; then
|
|
set -a
|
|
# shellcheck disable=SC1090
|
|
source "${_ENV_FILE}"
|
|
set +a
|
|
fi
|
|
|
|
_INGEST_URL="${INGEST_HEALTH_URL:-http://127.0.0.1:${PORT:-3041}/health}"
|
|
|
|
echo "verify: GET ${_INGEST_URL}"
|
|
if ! curl -sf "${_INGEST_URL}" >/dev/null; then
|
|
echo "verify: ingest /health failed" >&2
|
|
exit 1
|
|
fi
|
|
echo "verify: ingest OK"
|
|
|
|
if command -v mariadb-admin >/dev/null 2>&1 && [[ -n "${DATABASE_URL:-}" ]]; then
|
|
if [[ "${DATABASE_URL}" == mysql://* || "${DATABASE_URL}" == mariadb://* ]]; then
|
|
_PARSED="$(python3 -c "
|
|
import os
|
|
from urllib.parse import urlparse, unquote
|
|
u = urlparse(os.environ['DATABASE_URL'])
|
|
if u.scheme not in ('mysql', 'mariadb', 'mysqli'):
|
|
raise SystemExit(0)
|
|
host = u.hostname or '127.0.0.1'
|
|
port = u.port or 3306
|
|
user = unquote(u.username or '')
|
|
password = unquote(u.password or '')
|
|
print(host, port, user, password)
|
|
" 2>/dev/null)" || true
|
|
if [[ -n "${_PARSED}" ]]; then
|
|
read -r _h _p _u _pw <<< "${_PARSED}"
|
|
echo "verify: mariadb-admin ping (best-effort)"
|
|
mariadb-admin ping -h "${_h}" -P "${_p}" -u "${_u}" -p"${_pw}" --silent || true
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
_ADMIN_PORT="${ADMIN_UI_PORT:-3040}"
|
|
if curl -sf "http://127.0.0.1:${_ADMIN_PORT}/" >/dev/null 2>&1; then
|
|
echo "verify: admin-ui HTTP on port ${_ADMIN_PORT} OK"
|
|
else
|
|
echo "verify: admin-ui not responding on ${_ADMIN_PORT} (expected if service stopped or demo mode off)"
|
|
fi
|
|
|
|
# BIT-465: fail deploy if version.json is missing or invalid when path is configured.
|
|
if [[ -n "${ER_VERSION_JSON_PATH:-}" ]]; then
|
|
if [[ ! -f "${ER_VERSION_JSON_PATH}" ]]; then
|
|
echo "verify: ER_VERSION_JSON_PATH missing file: ${ER_VERSION_JSON_PATH}" >&2
|
|
exit 1
|
|
fi
|
|
python3 - "${ER_VERSION_JSON_PATH}" <<'PY'
|
|
import json
|
|
import sys
|
|
|
|
required = {"project", "commit", "branch", "builtAt", "builtBy"}
|
|
path = sys.argv[1]
|
|
with open(path, encoding="utf-8") as f:
|
|
data = json.load(f)
|
|
if not isinstance(data, dict):
|
|
sys.exit("verify: version.json root must be an object")
|
|
missing = required - data.keys()
|
|
if missing:
|
|
sys.exit("verify: version.json missing keys: " + ", ".join(sorted(missing)))
|
|
for k in required:
|
|
v = data[k]
|
|
if not isinstance(v, str) or not v.strip():
|
|
sys.exit(f"verify: version.json invalid empty field {k!r}")
|
|
PY
|
|
echo "verify: version.json OK (${ER_VERSION_JSON_PATH})"
|
|
fi
|
|
|
|
echo "verify: done"
|