From e86e52431f228ad3bd830ba4e6ffb84ab99bbdb1 Mon Sep 17 00:00:00 2001 From: Venkatesh Babu Date: Fri, 10 May 2024 15:36:12 +0530 Subject: [PATCH] All in one install --- install/ENV/.env-sandbox | 2 + install/START_BECKN.md | 8 +- install/beckn-onix.sh | 104 ++++++++++++++------ install/docker-compose-bpp-with-sandbox.yml | 14 +-- install/docker-compose-gcl.yml | 13 +-- install/docker-compose-v2.yml | 13 +-- install/docker-compose.yml | 15 +-- install/scripts/variables.sh | 2 +- install/start_beckn.sh | 5 - install/start_beckn_v2.sh | 5 - 10 files changed, 83 insertions(+), 98 deletions(-) create mode 100644 install/ENV/.env-sandbox diff --git a/install/ENV/.env-sandbox b/install/ENV/.env-sandbox new file mode 100644 index 0000000..d71b848 --- /dev/null +++ b/install/ENV/.env-sandbox @@ -0,0 +1,2 @@ +BPPCLIENTURL=http://bpp-client:6001 +BASE_URL=http://sandbox-api:3000 diff --git a/install/START_BECKN.md b/install/START_BECKN.md index 6853806..827b4bd 100644 --- a/install/START_BECKN.md +++ b/install/START_BECKN.md @@ -73,13 +73,7 @@ This shell script, `start_beckn_v2.sh`, automates the setup of Beckn components, ./start_container "sandbox-api" ``` -7. **Install Webhook:** - - ```bash - ./start_container "sandbox-webhook" - ``` - -8. **Install Protocol Server for BPP:** +7. **Install Protocol Server for BPP:** ```bash ./update_bpp_config.sh diff --git a/install/beckn-onix.sh b/install/beckn-onix.sh index e70ea42..984becc 100755 --- a/install/beckn-onix.sh +++ b/install/beckn-onix.sh @@ -162,24 +162,44 @@ install_bpp_protocol_server(){ echo "Protocol server BPP installation successful" } +# Function to install BPP Protocol Server with Sandbox +install_bpp_protocol_server_with_sandbox(){ + start_support_services + docker volume create bpp_client_config_volume + docker volume create bpp_network_config_volume + + echo "${GREEN}................Installing Sandbox................${NC}" + start_container $bpp_docker_compose_file_sandbox "sandbox-api" + sleep 5 + echo "Sandbox installation successful" -# MAIN SCRIPT STARTS HERE -#!/bin/bash + echo "${GREEN}................Installing Protocol Server for BPP................${NC}" + + if [[ $1 ]];then + registry_url=$1 + bpp_subscriber_id=$2 + bpp_subscriber_key_id=$3 + bpp_subscriber_url=$4 + webhook_url=$5 + bash scripts/update_bpp_config.sh $registry_url $bpp_subscriber_id $bpp_subscriber_key_id $bpp_subscriber_url $webhook_url + else + bash scripts/update_bpp_config.sh + fi -echo "Welcome to Beckn-ONIX!" -if [ -f ./onix_ascii_art.txt ]; then - cat ./onix_ascii_art.txt -else - echo "[Display Beckn-ONIX ASCII Art]" -fi + sleep 10 + 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 + docker run --rm -v $SCRIPT_DIR/../protocol-server-data:/source -v bpp_client_config_volume:/target busybox cp /source/bpp-client.yaml-sample /target + docker run --rm -v $SCRIPT_DIR/../protocol-server-data:/source -v bpp_network_config_volume:/target busybox cp /source/bpp-network.yml /target/default.yml + docker run --rm -v $SCRIPT_DIR/../protocol-server-data:/source -v bpp_network_config_volume:/target busybox cp /source/bpp-network.yaml-sample /target + docker rmi busybox -echo "Beckn-ONIX is a platform that helps you quickly launch and configure beckn-enabled networks." -echo -e "\nWhat would you like to do?\n1. Join an existing network\n2. Create new production network\n3. Set up a network on your local machine\n4. Merge multiple networks\n5. Configure Existing Network\n(Press Ctrl+C to exit)" -read -p "Enter your choice: " choice + start_container $bpp_docker_compose_file "bpp-client" + start_container $bpp_docker_compose_file "bpp-network" + sleep 10 + echo "Protocol server BPP installation successful" +} -boldGreen="\e[1m\e[92m" -reset="\e[0m" # Function to handle the setup process for each platform completeSetup() { @@ -254,25 +274,51 @@ completeSetup() { # Key generation and subscription logic follows here } -# Determine the platforms available based on the initial choice -platforms=("Gateway" "BAP" "BPP") -[ "$choice" -eq 2 ] && platforms=("Registry" "${platforms[@]}") # Add Registry for new network setups -echo "Great choice! Get ready." -echo -e "\nWhich platform would you like to set up?" -for i in "${!platforms[@]}"; do - echo "$((i+1)). ${platforms[$i]}" -done +# MAIN SCRIPT STARTS HERE -read -p "Enter your choice: " platform_choice - -selected_platform="${platforms[$((platform_choice-1))]}" - -if [[ -n $selected_platform ]]; then - completeSetup "$selected_platform" +echo "Welcome to Beckn-ONIX!" +if [ -f ./onix_ascii_art.txt ]; then + cat ./onix_ascii_art.txt else - echo "Invalid option. Please restart the script and select a valid option." - exit 1 + echo "[Display Beckn-ONIX ASCII Art]" +fi + +echo "Beckn-ONIX is a platform that helps you quickly launch and configure beckn-enabled networks." +echo -e "\nWhat would you like to do?\n1. Join an existing network\n2. Create new production network\n3. Set up a network on your local machine\n4. Merge multiple networks\n5. Configure Existing Network\n(Press Ctrl+C to exit)" +read -p "Enter your choice: " choice + +boldGreen="\e[1m\e[92m" +reset="\e[0m" + +if [[ $choice -eq 3 ]]; then + echo "Installing all components on the local machine" + install_package + install_registry + install_gateway + install_bap_protocol_server + install_bpp_protocol_server_with_sandbox +else + # Determine the platforms available based on the initial choice + platforms=("Gateway" "BAP" "BPP") + [ "$choice" -eq 2 ] && platforms=("Registry" "${platforms[@]}") # Add Registry for new network setups + + echo "Great choice! Get ready." + echo -e "\nWhich platform would you like to set up?" + for i in "${!platforms[@]}"; do + echo "$((i+1)). ${platforms[$i]}" + done + + read -p "Enter your choice: " platform_choice + + selected_platform="${platforms[$((platform_choice-1))]}" + + if [[ -n $selected_platform ]]; then + completeSetup "$selected_platform" + else + echo "Invalid option. Please restart the script and select a valid option." + exit 1 + fi fi echo "Process complete. Thank you for using Beckn-ONIX!" diff --git a/install/docker-compose-bpp-with-sandbox.yml b/install/docker-compose-bpp-with-sandbox.yml index 43ffea5..3b8dcc8 100644 --- a/install/docker-compose-bpp-with-sandbox.yml +++ b/install/docker-compose-bpp-with-sandbox.yml @@ -25,7 +25,6 @@ services: - bpp_network_schemas_volume:/usr/src/app/schemas - bpp_network_logs_volume:/usr/src/app/logs - sandbox-api: image: fidedocker/sandbox-api container_name: sandbox-api @@ -34,19 +33,8 @@ services: ports: - 4010:4000 restart: unless-stopped - - sandbox-webhook: - image: fidedocker/sandbox-webhook-api - depends_on: - - sandbox-api - container_name: sandbox-webhook - networks: - - beckn_network - ports: - - 3005:3005 - restart: unless-stopped volumes: - - ./ENV/.env-webhook:/usr/src/app/.env + - ./ENV/.env-sandbox:/usr/src/app/.env networks: beckn_network: diff --git a/install/docker-compose-gcl.yml b/install/docker-compose-gcl.yml index b73857b..67ba486 100644 --- a/install/docker-compose-gcl.yml +++ b/install/docker-compose-gcl.yml @@ -55,19 +55,8 @@ services: ports: - 4010:4000 restart: unless-stopped - - sandbox-webhook: - image: fidedocker/sandbox-webhook-api - depends_on: - - sandbox-api - container_name: sandbox-webhook - networks: - - beckn_network - ports: - - 3005:3005 - restart: unless-stopped volumes: - - ./ENV/.env-webhook:/usr/src/app/.env + - ./ENV/.env-sandbox:/usr/src/app/.env bpp-client: image: fidedocker/protocol-server diff --git a/install/docker-compose-v2.yml b/install/docker-compose-v2.yml index b73857b..67ba486 100644 --- a/install/docker-compose-v2.yml +++ b/install/docker-compose-v2.yml @@ -55,19 +55,8 @@ services: ports: - 4010:4000 restart: unless-stopped - - sandbox-webhook: - image: fidedocker/sandbox-webhook-api - depends_on: - - sandbox-api - container_name: sandbox-webhook - networks: - - beckn_network - ports: - - 3005:3005 - restart: unless-stopped volumes: - - ./ENV/.env-webhook:/usr/src/app/.env + - ./ENV/.env-sandbox:/usr/src/app/.env bpp-client: image: fidedocker/protocol-server diff --git a/install/docker-compose.yml b/install/docker-compose.yml index a7cea70..deeec38 100644 --- a/install/docker-compose.yml +++ b/install/docker-compose.yml @@ -66,21 +66,8 @@ services: ports: - 4010:4000 restart: unless-stopped - - sandbox-webhook: - image: fidedocker/sandbox-webhook-api - depends_on: - - registry - - gateway - - sandbox-api - container_name: sandbox-webhook - networks: - - beckn_network - ports: - - 3005:3005 - restart: unless-stopped volumes: - - ./ENV/.env-webhook:/usr/src/app/.env + - ./ENV/.env-sandbox:/usr/src/app/.env bpp-client: image: fidedocker/protocol-server diff --git a/install/scripts/variables.sh b/install/scripts/variables.sh index a753efe..fcda32f 100755 --- a/install/scripts/variables.sh +++ b/install/scripts/variables.sh @@ -50,7 +50,7 @@ bpp_network_port=6002 bpp_subscriber_id="bpp-network" bpp_subscriber_key_id="bpp-network-key" bpp_subscriber_url="http://bpp-network:6002" -webhook_url="http://sandbox-webhook:3005" +webhook_url="http://sandbox-api:3000" bpp_docker_compose_file=docker-compose-bpp.yml bpp_docker_compose_file_sandbox=docker-compose-bpp-with-sandbox.yml diff --git a/install/start_beckn.sh b/install/start_beckn.sh index af9b676..51df301 100755 --- a/install/start_beckn.sh +++ b/install/start_beckn.sh @@ -75,11 +75,6 @@ start_container "sandbox-api" sleep 5 echo "Sandbox installation successful" -echo "${GREEN}................Installing Webhook................${NC}" -start_container "sandbox-webhook" -sleep -echo "Webhook installation successful" - echo "${GREEN}................Installing Protocol Server for BPP................${NC}" bash scripts/update_bpp_config.sh sleep 10 diff --git a/install/start_beckn_v2.sh b/install/start_beckn_v2.sh index acf1f44..43864e9 100755 --- a/install/start_beckn_v2.sh +++ b/install/start_beckn_v2.sh @@ -127,11 +127,6 @@ install_bpp_protocol_server_with_sandbox(){ sleep 5 echo "Sandbox installation successful" - echo "${GREEN}................Installing Webhook................${NC}" - start_container $bpp_docker_compose_file_sandbox "sandbox-webhook" - sleep 5 - echo "Webhook installation successful" - echo "${GREEN}................Installing Protocol Server for BPP................${NC}" if [[ $1 ]];then