forked from hyperledger-labs/business-partner-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-ngrok.sh
executable file
·70 lines (50 loc) · 1.63 KB
/
start-ngrok.sh
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
# THIS IS FOR TESTING ONLY!
# Script starts ngrok https tunnels defined in ngrok.yml
# and sets the public endpoint as ACA-Py endpoint.
# Needs ngrok locally installed and an account with ngrok
# Check if web mode is enabled in .env
eval $(grep -i 'BPA_WEB_MODE' .env)
if [[ "$BPA_WEB_MODE" = "" ]]; then
BPA_WEB_MODE=false
fi
echo "Web Mode: $BPA_WEB_MODE"
# Run ngrok
if "$BPA_WEB_MODE"; then
NGROK_TUNNELS="businesspartner"
# Remove agent seed such that no public DID gets generated
export AGENT_SEED=""
else
NGROK_TUNNELS="acapyendpoint businesspartner"
fi
ngrok start --config ngrok.yml $NGROK_TUNNELS >/dev/null 2>&1 &
# Get public ip
function getTunnels () {
TUNNELS=$(curl --silent http://127.0.0.1:4040/api/tunnels | jq -c .tunnels[])
if [[ "$TUNNELS" == "" ]]; then
sleep 2
getTunnels
fi
}
getTunnels
for TUNNEL in $TUNNELS
do
TUNNEL_NAME=$( echo $TUNNEL | jq -r .name)
if [[ "$TUNNEL_NAME" == "acapyendpoint" ]]; then
ACA_PY_ENDPOINT=$( echo $TUNNEL | jq -r .public_url )
fi
if [[ "$TUNNEL_NAME" == "businesspartner" ]]; then
BPA_HOST=$( echo $TUNNEL | jq -r .public_url | sed 's/.*https:\/\///')
fi
done
# Generate random API Key
ACAPY_API_KEY=$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
export ACAPY_ADMIN_URL_API_KEY=$ACAPY_API_KEY
echo "ACA PY Admin Key: $ACAPY_API_KEY"
# write public ip to env
export BPA_HOST=$BPA_HOST
export AGENT_ENDPOINT=$ACA_PY_ENDPOINT
echo "Business Partner Agent Public URL: $BPA_HOST"
echo "Public ACA-PY Endpoint: $AGENT_ENDPOINT"
# Start agent
docker-compose up