#!/usr/bin/env bash # # print-core-token.sh — print the active core RPC bearer token for the # current deploy mode, so operators don't have to remember which side of the # Tauri-vs-CLI / Docker-vs-binary split owns the value. # # Resolution order (matches src/core/auth.rs::init_rpc_token): # 1. $OPENHUMAN_CORE_TOKEN if set and non-empty (Tauri / Docker / cloud) # 2. ${OPENHUMAN_WORKSPACE:-$HOME/.openhuman}/core.token (standalone CLI) # # Usage: # scripts/print-core-token.sh # print full token to stdout # scripts/print-core-token.sh --redact # print first 8 hex chars + '…' only # scripts/print-core-token.sh --where # print the source (env|file:path) # and exit without revealing the value # # Exit codes: # 0 success # 1 no token configured (neither env nor file) # 2 file exists but is unreadable / empty # # This script is read-only and never logs the token to syslog or to debug # files. When invoked from CI, prefer --redact + --where so logs stay safe. set -euo pipefail mode="full" for arg in "$@"; do case "$arg" in --redact) mode="redact" ;; --where) mode="where" ;; -h|--help) sed -n '2,21p' "$0" | sed 's/^# \{0,1\}//' exit 0 ;; *) echo "print-core-token: unknown argument '$arg'" >&2 exit 64 ;; esac done env_token="${OPENHUMAN_CORE_TOKEN:-}" workspace_dir="${OPENHUMAN_WORKSPACE:-$HOME/.openhuman}" file_path="$workspace_dir/core.token" source="" # one of: env | file token="" if [ -n "$env_token" ]; then source="env" token="$env_token" elif [ -f "$file_path" ]; then if [ ! -r "$file_path" ]; then echo "print-core-token: $file_path exists but is not readable by $USER" >&2 exit 2 fi token="$(tr -d '\n\r' < "$file_path" || true)" if [ -z "$token" ]; then echo "print-core-token: $file_path is empty" >&2 exit 2 fi source="file:$file_path" else cat >&2 <