Skip to content

Commit a953762

Browse files
committed
Added: Changes for BPP setup
1 parent 91c4a7b commit a953762

File tree

9 files changed

+109
-37
lines changed

9 files changed

+109
-37
lines changed

install/beckn-onix.sh

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ install_layer2_config() {
131131

132132
# Function to install BAP Protocol Server
133133
install_bap_protocol_server() {
134-
# start_support_services # Start MongoDB, RabbitMQ, and Redis services
134+
start_support_services # Start MongoDB, RabbitMQ, and Redis services
135135
# POST containers are started, now update the configuration
136136
if [[ $1 ]]; then
137137
# If parameters are provided, use them to update the configuration
@@ -147,7 +147,6 @@ install_bap_protocol_server() {
147147

148148

149149
sleep 10
150-
return
151150

152151
docker volume create bap_client_config_volume
153152
docker volume create bap_network_config_volume
@@ -175,12 +174,12 @@ install_bap_protocol_server() {
175174
# Keep trying API call until we get 200 status
176175
status_code=0
177176
attempt=1
178-
max_attempts=5
177+
max_attempts=10
179178

180-
while [ $status_code -ne 200 ] && [ $attempt -le $max_attempts ]; do
181-
echo "Attempt $attempt of $max_attempts to verify BAP protocol server..."
179+
while [ $status_code -ne 200 ]; do
180+
echo "Checking BAP protocol server health..."
182181

183-
response=$(curl -s -w "%{http_code}" --location "$bap_subscriber_url/status" \
182+
response=$(curl -s -w "%{http_code}" --location "$bap_subscriber_url/health" \
184183
-H "Content-Type: application/json")
185184

186185
status_code="${response: -3}"
@@ -195,11 +194,7 @@ install_bap_protocol_server() {
195194
fi
196195
done
197196

198-
if [ $status_code -ne 200 ]; then
199-
echo "${RED}Failed to verify BAP protocol server after $max_attempts attempts${NC}"
200-
exit 1
201-
fi
202-
197+
203198

204199
echo "${BLUE}Registering BAP protocol server on the registry${NC}"
205200
create_network_participant "$registry_url" "application/json" "$bap_subscriber_id" "$bap_subscriber_key_id" "$bap_subscriber_url" "$public_key" "$public_key" "$valid_from" "$valid_until" "$type" "$api_key" "$np_domain"
@@ -210,21 +205,26 @@ install_bap_protocol_server() {
210205

211206
# Function to install BPP Protocol Server without Sandbox
212207
install_bpp_protocol_server() {
213-
start_support_services
208+
start_support_services # Start MongoDB, RabbitMQ, and Redis services
209+
# POST containers are started, now update the configuration
214210
echo "${GREEN}................Installing Protocol Server for BPP................${NC}"
215211

216212
if [[ $1 ]]; then
213+
# If parameters are provided, use them to update the configuration
217214
registry_url=$1
218215
bpp_subscriber_id=$2
219216
bpp_subscriber_key_id=$3
220217
bpp_subscriber_url=$4
221-
webhook_url=$5
222-
bash scripts/update_bpp_config.sh $registry_url $bpp_subscriber_id $bpp_subscriber_key_id $bpp_subscriber_url $webhook_url $api_key $np_domain
218+
webhook_url=$5
219+
source scripts/update_bpp_config.sh $registry_url $bpp_subscriber_id $bpp_subscriber_key_id $bpp_subscriber_url $webhook_url $api_key "$np_domain"
220+
223221
else
224-
bash scripts/update_bpp_config.sh
222+
# If no parameters are provided, use the default configuration
223+
source scripts/update_bpp_config.sh
225224
fi
226225

227226
sleep 10
227+
228228
docker volume create bpp_client_config_volume
229229
docker volume create bpp_network_config_volume
230230
docker run --rm -v $SCRIPT_DIR/../protocol-server-data:/source -v bpp_client_config_volume:/target busybox cp /source/bpp-client.yml /target/default.yml
@@ -244,6 +244,33 @@ install_bpp_protocol_server() {
244244
install_layer2_config bpp-client
245245
install_layer2_config bpp-network
246246
fi
247+
248+
# Keep trying API call until we get 200 status
249+
status_code=0
250+
attempt=1
251+
max_attempts=10
252+
253+
while [ $status_code -ne 200 ]; do
254+
echo "Checking BPP protocol server health..."
255+
256+
response=$(curl -s -w "%{http_code}" --location "$bpp_subscriber_url/health" \
257+
-H "Content-Type: application/json")
258+
259+
status_code="${response: -3}"
260+
261+
if [ $status_code -eq 200 ]; then
262+
echo "${GREEN}BPP protocol server is up and running${NC}"
263+
break
264+
else
265+
echo "${YELLOW}BPP protocol server not ready yet (status: $status_code). Retrying in 5 seconds...${NC}"
266+
sleep 5
267+
((attempt++))
268+
fi
269+
done
270+
271+
echo "${BLUE}Registering BPP protocol server on the registry${NC}"
272+
create_network_participant "$registry_url" "application/json" "$bpp_subscriber_id" "$bpp_subscriber_key_id" "$bpp_subscriber_url" "$public_key" "$public_key" "$valid_from" "$valid_until" "$type" "$api_key" "$np_domain"
273+
247274
echo "Protocol server BPP installation successful"
248275
}
249276

@@ -373,7 +400,7 @@ validate_user() {
373400

374401
# Replace '/subscribers' with '/login' for validation
375402
local login_url="${registry_url%/subscribers}/auth/local"
376-
echo "login_url: $login_url"
403+
377404

378405
# Validate credentials using a POST request
379406
local response
@@ -387,7 +414,7 @@ validate_user() {
387414
if [ "$status_code" -eq 200 ]; then
388415
response_body="${response%???}"
389416
api_key=$(echo "$response_body" | jq -r '.jwt')
390-
echo "api_key: $api_key"
417+
391418
return 0
392419
else
393420
response=$(curl -s -w "%{http_code}" --location "$login_url" \
@@ -523,24 +550,30 @@ completeSetup() {
523550
public_address=$bap_subscriber_url
524551

525552
layer2_config
526-
# install_package
553+
install_package
527554
install_bap_protocol_server $registry_url $bap_subscriber_id $bap_subscriber_key_id $bap_subscriber_url
528555

529556

530557
;;
531558
"BPP")
532-
echo "${GREEN}................Installing Protocol Server for BPP................${NC}"
533559

560+
# Display installation header
561+
echo "${GREEN}................Installing Protocol Server for BPP................${NC}"
562+
563+
# Step 1: Get BPP Subscriber ID
534564
read -p "Enter BPP Subscriber ID: " bpp_subscriber_id
565+
566+
# Step 2: Get and validate BPP Subscriber URL
535567
while true; do
536568
read -p "Enter BPP Subscriber URL: " bpp_subscriber_url
537569
if [[ $bpp_subscriber_url =~ ^(http|https):// ]]; then
538-
break
570+
break # Valid URL format, exit loop
539571
else
540572
echo "${RED}Invalid URL format. Please enter a valid URL starting with http:// or https://.${NC}"
541573
fi
542574
done
543575

576+
# Step 3: Get and validate Webhook URL
544577
while true; do
545578
read -p "Enter Webhook URL: " webhook_url
546579
if [[ $webhook_url =~ ^(http|https):// ]]; then
@@ -550,19 +583,23 @@ completeSetup() {
550583
fi
551584
done
552585

586+
# Step 4: Get and validate Registry URL
553587
while true; do
554588
read -p "Enter the registry URL (e.g., https://registry.becknprotocol.io/subscribers): " registry_url
555-
if [[ $registry_url =~ ^(http|https):// ]] && [[ $registry_url == */subscribers ]]; then
556-
break
589+
if [[ $registry_url =~ ^(http|https):// ]]; then
590+
break # Valid URL format, exit loop
557591
else
558592
echo "${RED}Please mention /subscribers in your registry URL${NC}"
559593
fi
560594
done
595+
596+
# Step 5: Validate user credentials
561597
validate_user
562598
if [ $? -eq 1 ]; then
563599
exit
564600
fi
565601

602+
# Step 6: Get and validate NP Domain
566603
get_np_domain $bpp_subscriber_id
567604
if [ $? -eq 1 ]; then
568605
exit

install/docker-compose-bap.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
services:
22
bap-client:
3-
image: fidedocker/protocol-server
3+
image: fidedocker/protocol-server:multiarch
44
container_name: bap-client
5-
platform: linux/amd64
5+
# platform: linux/amd64
66
networks:
77
- beckn_network
88
ports:
@@ -14,9 +14,9 @@ services:
1414
- bap_client_logs_volume:/usr/src/app/logs
1515

1616
bap-network:
17-
image: fidedocker/protocol-server
17+
image: fidedocker/protocol-server:multiarch
1818
container_name: bap-network
19-
platform: linux/amd64
19+
# platform: linux/amd64
2020
networks:
2121
- beckn_network
2222
ports:

install/docker-compose-bpp.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
services:
22
bpp-client:
3-
image: fidedocker/protocol-server
3+
image: fidedocker/protocol-server:multiarch
44
container_name: bpp-client
5-
platform: linux/amd64
5+
# platform: linux/amd64
66
networks:
77
- beckn_network
88
ports:
@@ -14,9 +14,9 @@ services:
1414
- bpp_client_logs_volume:/usr/src/app/logs
1515

1616
bpp-network:
17-
image: fidedocker/protocol-server
17+
image: fidedocker/protocol-server:multiarch
1818
container_name: bpp-network
19-
platform: linux/amd64
19+
# platform: linux/amd64
2020
networks:
2121
- beckn_network
2222
ports:

install/protocol-server-data/bap-client.yaml-sample

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,15 @@ app:
132132
syncInterval: 30
133133
redis_db: 3
134134

135+
useHMACForWebhook: false
136+
sharedKeyForWebhookHMAC: ""
137+
135138
useLayer2Config: USE_LAYER_2_CONFIG
136139
mandateLayer2Config: MANDATE_LAYER_2_CONFIG
137140

141+
openAPIValidator:
142+
cachedFileLimit: 5
143+
initialFilesToCache: ""
144+
145+
streamOnSearch: false
138146

install/protocol-server-data/bap-network.yaml-sample

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,14 @@ app:
132132
syncInterval: 30
133133
redis_db: 3
134134

135+
useHMACForWebhook: false
136+
sharedKeyForWebhookHMAC: ""
137+
135138
useLayer2Config: USE_LAYER_2_CONFIG
136-
mandateLayer2Config: MANDATE_LAYER_2_CONFIG
139+
mandateLayer2Config: MANDATE_LAYER_2_CONFIG
140+
141+
openAPIValidator:
142+
cachedFileLimit: 5
143+
initialFilesToCache: ""
144+
145+
streamOnSearch: false

install/protocol-server-data/bpp-client.yaml-sample

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,14 @@ app:
130130
syncInterval: 30
131131
redis_db: 3
132132

133+
useHMACForWebhook: false
134+
sharedKeyForWebhookHMAC: ""
135+
133136
useLayer2Config: USE_LAYER_2_CONFIG
134-
mandateLayer2Config: MANDATE_LAYER_2_CONFIG
137+
mandateLayer2Config: MANDATE_LAYER_2_CONFIG
138+
139+
openAPIValidator:
140+
cachedFileLimit: 5
141+
initialFilesToCache: ""
142+
143+
streamOnSearch: false

install/protocol-server-data/bpp-network.yaml-sample

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,14 @@ app:
130130
syncInterval: 30
131131
redis_db: 3
132132

133+
useHMACForWebhook: false
134+
sharedKeyForWebhookHMAC: ""
135+
133136
useLayer2Config: USE_LAYER_2_CONFIG
134-
mandateLayer2Config: MANDATE_LAYER_2_CONFIG
137+
mandateLayer2Config: MANDATE_LAYER_2_CONFIG
138+
139+
openAPIValidator:
140+
cachedFileLimit: 5
141+
initialFilesToCache: ""
142+
143+
streamOnSearch: false

install/scripts/registry_entry.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,13 @@ create_network_participant() {
4545
EOF
4646
)
4747
echo "json_data: $json_data"
48-
4948
response=$(curl --location "$registry_url/subscribers/subscribe" \
5049
--header "Authorization: Bearer $api_key" \
5150
--header "Content-Type: $content_type" \
5251
--data "$json_data" 2>&1)
5352
if [ $? -eq 0 ]; then
5453

55-
echo "${GREEN}Network Participant Entry is created. Please login to registry $registry_url and subscribe you Network Participant.${NC}"
54+
echo "${GREEN}Network Participant Entry is created. And subscribed to the registry $registry_url. ${NC}"
5655
else
5756
echo "${RED}Error: $response${NC}"
5857
fi

install/scripts/update_bpp_config.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ else
126126
done
127127
fi
128128

129-
echo "Registering BPP protocol server on the registry"
129+
# Commenting out the create_network_participant function call from here as it will be called after the container is started
130+
# echo "Registering BPP protocol server on the registry"
130131

131-
create_network_participant "$registry_url" "application/json" "$bpp_subscriber_id" "$bpp_subscriber_key_id" "$bpp_subscriber_url" "$public_key" "$public_key" "$valid_from" "$valid_until" "$type" "$api_key" "$np_domain"
132+
# create_network_participant "$registry_url" "application/json" "$bpp_subscriber_id" "$bpp_subscriber_key_id" "$bpp_subscriber_url" "$public_key" "$public_key" "$valid_from" "$valid_until" "$type" "$api_key" "$np_domain"

0 commit comments

Comments
 (0)