SPB Git

Repository Public License

with-dev-keys.sh 1.8 KB 30 lines shellscript

1#!/usr/bin/env bash2# ORIX OS Automation3# File: Scripts/test/with-dev-keys.sh4# Description: Developer-only credential broker. Runs a command with the SP Chat development provider keys injected into ITS environment only; never prints, copies or stores them.5#6# Author: Simon-Pierre Boucher7# Contact: contact@spboucher.ai8#   Scripts/test/with-dev-keys.sh --check            # report which keys are present (names and lengths only)9#   Scripts/test/with-dev-keys.sh <command> [args…]  # run a command with ORIX_DEV_*_API_KEY set10# Source of the keys: the operator's existing secrets file for the SP Chat deployment, outside this repository11# (override with ORIX_DEV_SECRETS_FILE). The file is read line by line; values go straight to the child's environment.12set -euo pipefail13FILE="${ORIX_DEV_SECRETS_FILE:-$HOME/Desktop/Cluster/secrets/chat-spboucher-ai.env}"14[[ -r "$FILE" ]] || { echo "with-dev-keys: secrets file not readable (set ORIX_DEV_SECRETS_FILE). Live provider tests will be skipped." >&2; exit 78; }15read_key() { # $1 = variable name in the file16  local line; line="$(grep -E "^(export[[:space:]]+)?$1=" "$FILE" | tail -1 || true)"17  line="${line#export }"; line="${line#*=}"; line="${line%\"}"; line="${line#\"}"; line="${line%\'}"; line="${line#\'}"18  printf '%s' "$line"19}20A="$(read_key ANTHROPIC_API_KEY)"; O="$(read_key OPENAI_API_KEY)"; R="$(read_key OPENROUTER_API_KEY)"21if [[ "${1:-}" == "--check" ]]; then22  for pair in "ANTHROPIC:${#A}" "OPENAI:${#O}" "OPENROUTER:${#R}"; do23    name="${pair%%:*}"; len="${pair##*:}"24    if [[ "$len" -gt 0 ]]; then echo "$name: present (length $len)"; else echo "$name: MISSING"; fi25  done26  exit 027fi28[[ $# -gt 0 ]] || { echo "usage: $0 --check | <command> [args…]" >&2; exit 2; }29ORIX_DEV_ANTHROPIC_API_KEY="$A" ORIX_DEV_OPENAI_API_KEY="$O" ORIX_DEV_OPENROUTER_API_KEY="$R" exec "$@"30
Files main
Menu

Theme