adaptai / platform /aiml /mlops /dbops_tools /render_janus_props.sh
ADAPT-Chase's picture
Add files using upload-large-folder tool
93be2a2 verified
#!/usr/bin/env bash
set -euo pipefail
# Render JanusGraph CQL properties with secrets and launch Gremlin Server.
# Defaults align with your new dbops tree.
DBOPS_ROOT="${DBOPS_ROOT:-/data/adaptai/platform/dbops}"
SECRETS_DIR="${SECRETS_DIR:-/data/adaptai/secrets/dataops}"
CONF_DIR="$DBOPS_ROOT/configs/janusgraph"
RUNTIME_DIR="$DBOPS_ROOT/run/janusgraph"
mkdir -p "$RUNTIME_DIR"
TEMPLATE="$CONF_DIR/janusgraph-cql.properties"
OUT="$RUNTIME_DIR/janusgraph-cql.runtime.properties"
# Load secrets (.env key=val) into env without overriding existing vars
if [[ -f "$SECRETS_DIR/.env" ]]; then
while IFS='=' read -r k v; do
[[ -z "$k" ]] && continue
[[ "$k" =~ ^# ]] && continue
[[ -z "$v" ]] && continue
if [[ -z "${!k-}" ]]; then export "$k"="$v"; fi
done < <(grep -v '^#' "$SECRETS_DIR/.env" | sed '/^$/d')
fi
if [[ -z "${SCYLLA_USER:-}" || -z "${SCYLLA_PASS:-}" ]]; then
echo "[janus] Missing SCYLLA_USER or SCYLLA_PASS in $SECRETS_DIR/.env" >&2
exit 1
fi
# Simple env substitution for ${VAR} placeholders
awk '{print}' "$TEMPLATE" \
| sed "s#\${SCYLLA_USER}#${SCYLLA_USER}#g" \
| sed "s#\${SCYLLA_PASS}#${SCYLLA_PASS}#g" \
> "$OUT"
echo "[janus] Rendered: $OUT"
# Launch Gremlin Server with rendered properties
GREMLIN_YAML="$CONF_DIR/gremlin-server.yaml"
if [[ -n "${START_GREMLIN:-1}" && "${START_GREMLIN}" != "0" ]]; then
echo "[janus] Starting Gremlin Server on port configured in $GREMLIN_YAML"
# Assume janusgraph distribution bin/gremlin-server.sh is on PATH or under dbops/bin
if command -v gremlin-server.sh >/dev/null 2>&1; then
exec gremlin-server.sh start "$GREMLIN_YAML"
elif [[ -x "$DBOPS_ROOT/bin/gremlin-server.sh" ]]; then
exec "$DBOPS_ROOT/bin/gremlin-server.sh" start "$GREMLIN_YAML"
else
echo "[janus] gremlin-server.sh not found; start it with the above config manually." >&2
exit 2
fi
fi