-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_with_ngrok.sh
More file actions
executable file
·46 lines (37 loc) · 1.22 KB
/
Copy pathstart_with_ngrok.sh
File metadata and controls
executable file
·46 lines (37 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Start the backend + ngrok, then auto-configure AgentPhone
# Usage: ./start_with_ngrok.sh
set -e
PORT=8001
echo "Starting Threat Vector backend on port $PORT..."
python main.py &
BACKEND_PID=$!
sleep 2
echo "Starting ngrok tunnel..."
ngrok http $PORT --log=stdout --log-format=json > /tmp/ngrok.log 2>&1 &
NGROK_PID=$!
sleep 3
# Extract public URL from ngrok API
NGROK_URL=$(curl -s http://localhost:4040/api/tunnels | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['tunnels'][0]['public_url'])" 2>/dev/null)
if [ -z "$NGROK_URL" ]; then
echo "ERROR: Could not get ngrok URL. Is ngrok installed?"
kill $BACKEND_PID $NGROK_PID 2>/dev/null
exit 1
fi
echo ""
echo "==========================================="
echo " ngrok URL: $NGROK_URL"
echo " Webhook: $NGROK_URL/webhook/agentphone"
echo "==========================================="
echo ""
# Update .env with the ngrok URL
sed -i.bak "s|NGROK_URL=.*|NGROK_URL=$NGROK_URL|" .env
echo "Updated .env with NGROK_URL=$NGROK_URL"
# Configure AgentPhone
echo "Configuring AgentPhone agent..."
python setup_agentphone.py "$NGROK_URL"
echo ""
echo "Ready! Call +12402665263 to test Threat Vector."
echo ""
echo "Press Ctrl+C to stop."
wait $BACKEND_PID