#!/bin/sh # Create synthetic probe credentials in an explicit private directory; print no secrets. set -eu : "${BASE_URL:?}" "${PROBE_WORK:?}" umask 077 mkdir -p "$PROBE_WORK" username="observe_$(openssl rand -hex 6)" password=$(openssl rand -hex 16) jq -n --arg username "$username" --arg password "$password" '{username:$username,display_name:"Observability probe",password:$password}' > "$PROBE_WORK/user.json" curl -fsS "$BASE_URL/api/v1/users" -H 'Content-Type: application/json' --data-binary @"$PROBE_WORK/user.json" > "$PROBE_WORK/user-response.json" printf 'user = "%s:%s"\n' "$username" "$password" > "$PROBE_WORK/basic.conf" curl -fsS --config "$PROBE_WORK/basic.conf" -X POST "$BASE_URL/api/v1/auth/sessions" > "$PROBE_WORK/session.json" printf 'header = "Authorization: Bearer %s"\n' "$(jq -r .token "$PROBE_WORK/session.json")" > "$PROBE_WORK/auth.conf" jq -n --arg id "$(jq -r .id "$PROBE_WORK/user-response.json")" '{title:"Observability probe",member_ids:[$id]}' > "$PROBE_WORK/chat.json" curl -fsS --config "$PROBE_WORK/auth.conf" "$BASE_URL/api/v1/chats" -H 'Content-Type: application/json' --data-binary @"$PROBE_WORK/chat.json" > "$PROBE_WORK/chat-response.json" printf '%s\n' "$(jq -r .id "$PROBE_WORK/chat-response.json")" > "$PROBE_WORK/chat-id"