Skip to content

Instantly share code, notes, and snippets.

@sandromello
Last active July 11, 2024 18:41
Show Gist options
  • Save sandromello/055e809a5c43a9dcfa6995a5f1b9aaf7 to your computer and use it in GitHub Desktop.
Save sandromello/055e809a5c43a9dcfa6995a5f1b9aaf7 to your computer and use it in GitHub Desktop.
System Agent
#!/bin/bash
SECRET_KEY=xagt-$(LC_ALL=C tr -dc A-Za-z0-9_ < /dev/urandom | head -c 43 | xargs)
set -eo pipefail
SECRET_KEY_HASH=$(echo -n $SECRET_KEY | sha256sum |awk {'print $1'})
psql -v ON_ERROR_STOP=1 "$POSTGRES_DB_URI" <<EOF
BEGIN;
DELETE FROM agents WHERE name = 'system';
INSERT INTO agents (id, org_id, name, mode, key_hash, status)
VALUES ('9A7C5A60-C910-4AD1-8A70-997E37123894', (SELECT id from private.orgs), 'system', 'standard', '$SECRET_KEY_HASH', 'DISCONNECTED')
ON CONFLICT DO NOTHING;
COMMIT;
EOF
HOOP_KEY=grpc://system:$SECRET_KEY@127.0.0.1:8010?mode=standard /opt/hoop/bin/hoop start agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment