gabriel / musehub public
seed.sh bash
52 lines 2.0 KB
7f1d07e8 feat: domains, MCP expansion, MIDI player, and production hardening (#8) Gabriel Cardona <cgcardona@gmail.com> 4d ago
1 #!/usr/bin/env bash
2 # Run ON the EC2 instance after the app is live.
3 # Creates your admin account, mints a JWT, seeds code repos + MIDI repos.
4 #
5 # Usage:
6 # ssh -i ~/.ssh/musehub-key.pem ubuntu@musehub.ai
7 # chmod +x /opt/musehub/deploy/seed.sh && /opt/musehub/deploy/seed.sh
8
9 set -euo pipefail
10
11 APP_DIR="/opt/musehub"
12 CONTAINER="musehub-musehub-1" # adjust if docker compose names it differently
13
14 echo "==> Checking container name..."
15 CONTAINER=$(sudo docker compose -f "$APP_DIR/docker-compose.yml" ps --format json | python3 -c "import sys,json; d=json.load(sys.stdin); print(d[0]['Name'])" 2>/dev/null || echo "musehub-musehub-1")
16 echo " Container: $CONTAINER"
17
18 echo "==> Running seed_production.py (gabriel's account + 5 code repos + 5 MIDI repos)..."
19 sudo docker compose -f "$APP_DIR/docker-compose.yml" exec musehub \
20 python3 /app/scripts/seed_production.py
21
22 echo "==> Minting admin JWT for gabriel..."
23 sudo docker compose -f "$APP_DIR/docker-compose.yml" exec musehub python3 - << 'PYEOF'
24 import hashlib, uuid
25 from musehub.auth.tokens import generate_access_code
26
27 # Same stable ID used by seed_production.py
28 GABRIEL_ID = str(uuid.UUID(bytes=hashlib.md5("prod-gabriel-cgcardona".encode()).digest()))
29 token = generate_access_code(user_id=GABRIEL_ID, duration_days=365, is_admin=True)
30
31 print("\n" + "="*60)
32 print("ADMIN JWT FOR gabriel (valid 365 days):")
33 print("="*60)
34 print(token)
35 print("="*60)
36 print("\nAdd to your Muse CLI config:")
37 print(f" muse config set hub.token {token}")
38 print(f" muse config set hub.url https://musehub.ai")
39 print("="*60 + "\n")
40 PYEOF
41
42 echo ""
43 echo "============================================================"
44 echo " SEED COMPLETE"
45 echo "============================================================"
46 echo " Copy the JWT above and configure your Muse CLI:"
47 echo " muse config set hub.token <token>"
48 echo " muse config set hub.url https://musehub.ai"
49 echo ""
50 echo " Then you can push repos:"
51 echo " cd ~/path/to/muse && muse push"
52 echo "============================================================"