#!/usr/bin/env bash # Runs obs-beacond, the agent's helper and the agent on this machine, for # development. Everything stays on 127.0.0.1; state lives in dev/state/ # (delete beacon.db there to start over). # Open http://localhost:8150/ and use "Sign in for local development". set -euo pipefail cd "$(dirname "$0")/.." state=dev/state mkdir -p "$state" if [[ ! -s $state/agent.token ]]; then ./bin/obs-beacond token | sed -n '2p' | tr -d ' ' > "$state/agent.token" chmod 600 "$state/agent.token" fi if [[ ! -s $state/state.key ]]; then (umask 077; head -c 32 /dev/urandom | base64 > "$state/state.key") fi hash=$(tr -d '\n' < "$state/agent.token" | sha256sum | cut -c1-64) host=$(hostname -s) # Expect this machine's two running containers, plus one that only exists # while you run it, so alerts can be watched firing and resolving: # docker run -d --rm --name beacon-demo-sleeper sleep 600 cat > "$state/expected.yaml" < "$state/checks.yaml" < "$state/topology.yaml" < "$state/obs-beacond.yaml" </dev/null || true; wait 2>/dev/null || true; } trap cleanup EXIT INT TERM # A stand-in for inbuxa's sign-in, so the real flow can be clicked through. go run ./dev/fakeinbuxa & pids+=($!) ./bin/obs-beacond -config "$state/obs-beacond.yaml" & pids+=($!) # The agent pins obs-beacond's agent CA, made on its first start. Wait # until obs-beacond answers: agent-ca.pem may be left from an older database. for _ in $(seq 100); do curl -sf -o /dev/null http://127.0.0.1:8150/healthz && break; sleep 0.1; done fingerprint=$(./bin/obs-beacond ca -config "$state/obs-beacond.yaml" | sed -n '2p' | tr -d ' ') cat > "$state/agent.yaml" <