setup_encryption.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. echo "=== Letta Schedules Encryption Setup ==="
  3. echo ""
  4. # Check if modal is installed
  5. if ! command -v modal &> /dev/null; then
  6. echo "ERROR: modal CLI not found. Install with: pip install modal"
  7. exit 1
  8. fi
  9. # Check if user is authenticated
  10. if ! modal profile list &> /dev/null; then
  11. echo "ERROR: Not authenticated with Modal. Run: modal setup"
  12. exit 1
  13. fi
  14. echo "Generating encryption key..."
  15. ENCRYPTION_KEY=$(python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())")
  16. if [ -z "$ENCRYPTION_KEY" ]; then
  17. echo "ERROR: Failed to generate encryption key"
  18. exit 1
  19. fi
  20. echo "Generated encryption key: ${ENCRYPTION_KEY:0:20}..."
  21. echo ""
  22. echo "Creating Modal secret 'letta-switchboard-encryption'..."
  23. # Check if secret already exists
  24. if modal secret list | grep -q "letta-switchboard-encryption"; then
  25. echo "WARNING: Secret 'letta-switchboard-encryption' already exists."
  26. echo "Delete it first with: modal secret delete letta-switchboard-encryption"
  27. exit 1
  28. fi
  29. # Create the secret
  30. modal secret create letta-switchboard-encryption LETTA_SWITCHBOARD_ENCRYPTION_KEY="$ENCRYPTION_KEY" 2>&1
  31. if [ $? -eq 0 ]; then
  32. echo ""
  33. echo "✅ Success! Encryption secret created."
  34. echo ""
  35. echo "IMPORTANT: Save this key securely!"
  36. echo "Encryption key: $ENCRYPTION_KEY"
  37. echo ""
  38. echo "If you lose this key, all encrypted schedules will be unrecoverable."
  39. echo ""
  40. echo "Next step: modal deploy app.py"
  41. else
  42. echo ""
  43. echo "❌ Failed to create secret. Error above."
  44. exit 1
  45. fi