Files
KNELAgentIdentityProvisioning/skills/agent-provisioning/scripts/cloudron-api.sh
T
mrcharles 0076b4f941 docs: reachableceo wording sweep per 2026-09-09 direct order
House style: the principal identity is named (reachableceo), never
'the founder'. No behavior change.

https://projects.knownelement.com/issues/942
2026-09-09 12:43:23 -05:00

24 lines
999 B
Bash
Executable File

#!/bin/bash
# Authenticated Cloudron admin API call (compliant lever: api-token service
# account from vault item creds/cloudron — never reachableceo's accounts).
# usage: cloudron-api.sh METHOD /api/v1/PATH [JSON-BODY]
# body -> stdout; HTTP status -> stderr. Secrets never printed.
set -euo pipefail
BASE="https://my.knownelement.com"
METHOD="${1:?usage: cloudron-api.sh METHOD /api/v1/PATH [JSON-BODY]}"
PATHPART="${2:?usage: cloudron-api.sh METHOD /api/v1/PATH [JSON-BODY]}"
BODY="${3:-}"
if [ "$(id -un)" = "TSGCOO" ]; then
SM() { /data2/TSGCOO/.local/bin/sm "$@" </dev/null; }
else
SM() { sudo -u TSGCOO /data2/TSGCOO/.local/bin/sm "$@" </dev/null; }
fi
TOKEN=$(SM get creds/cloudron --field password)
[ -n "$TOKEN" ] || { echo "no cloudron token in vault" >&2; exit 1; }
ARGS=(-sk -X "$METHOD" "$BASE$PATHPART"
-H "Authorization: Bearer $TOKEN"
-H 'Content-Type: application/json'
-w '\nHTTP %{http_code}\n')
[ -n "$BODY" ] && ARGS+=(-d "$BODY")
curl "${ARGS[@]}" >&2