Onix Version 0.2 - migrate from beckn-utilities

This commit is contained in:
Venkatesh Babu
2024-03-18 17:12:46 +05:30
parent 8570746b0c
commit 48c80712a2
39 changed files with 2417 additions and 2 deletions

View File

@@ -1,2 +1,7 @@
# onix # ONIX
beckn onix
ONIX - Open Network In A Box, is a project designed to effortlessly set up and maintain Beckn network that is scalable, secure and easy to maintain.
In the install folder, you find a tool that helps install a Beckn network. This tool serves as a valuable resource for developers and network participants eager to explore BECKN protocols or join open networks supported by the BECKN protocol. By simplifying the installation process, ONIX streamlines the onboarding experience. For more details, refer to [release notes](./install/RELEASE.md) and [start with Beckn](./install/START_BECKN.md)
Experience the convenience and efficiency of ONIX as you embark on your journey with BECKN protocols and open networks.

11
install/.gitignore vendored Normal file
View File

@@ -0,0 +1,11 @@
docker_data
gateway_data/config/swf.properties
registry_data/config/swf.properties
.vscode
protocol-server-data/bap-client.yml
protocol-server-data/bap-network.yml
protocol-server-data/bpp-client.yml
protocol-server-data/bpp-network.yml
ENV/.env-generic-client-layer
registry.lock*
gateway.lock*

View File

@@ -0,0 +1,19 @@
APP_NAME="Generic Client Layer"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_PORT=3000
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
PS_BASE_URI=BAP_CLIENT_URL
PS_BAP_ID=BAP_SUBSCRIBER_ID
PS_BAP_URI=BAP_SUBSCRIBER_URL
PS_CITY_NAME=Bangalore
PS_CITY_CODE=std:080
PS_COUNTRY_NAME=India
PS_COUNTRY_CODE=IND

2
install/ENV/.env-webhook Normal file
View File

@@ -0,0 +1,2 @@
SANDBOXURL=http://sandbox-api:3000
BPPCLIENTURL=http://bpp-client:6001

51
install/RELEASE.md Normal file
View File

@@ -0,0 +1,51 @@
# Release Notes
### Objective
ONIX - Open Network In A Box. This install utility is designed to effortlessly set up all BECKN components on a machine using a one-click installer. This tool serves as a valuable resource for developers and network participants eager to explore BECKN protocols or join open networks supported by the BECKN protocol. By simplifying the installation process, ONIX streamlines the onboarding experience.
Experience the convenience and efficiency of ONIX as you embark on your journey with BECKN protocols and open networks.
| Version | Release Date |
| ------------------------------------------------------------------------------------------ | ------------ |
| [v0.1.0](https://github.com/beckn/beckn-utilities/blob/main/onix/release/RELEASE_0.1.0.md) | 2024-02-16 |
## ONIX Version 0.2.0 (2024-03-01)
### New Features
- This release focuses on enabling the installation of individual components with user-provided configurations.
- It extends support to the Windows operating system, specifically Windows 10.
- Additionally, it now supports the Mac operating system.
This release is specifically designed to facilitate the deployment of individual components, offering users the flexibility to customize configurations. Furthermore, it ensures seamless compatibility with both Windows and Mac operating systems.
For a comprehensive summary of the features, refer [here](https://github.com/beckn/beckn-utilities/milestone/1?closed=1)
### Enhancements
- Support for Windows operating system.
- Support for Mac operating system.
- Can be used to install specific components with custom configuration.
### Bug Fixes
- None
### Known Issues
- None
### Limitations
- The current installer is tested only for Linux (Ubuntu) / Windows (windows 10) / Mac, it might support other flavors also.
- The current version supports only vertical scaling, horizontal scaling (ECS / EKS) is planned for an upcoming release
- When installing individual components, registration with the registry has to be done manually, this is explicitly done to avoid confusion and to prevent the network from incorrect or wrong registrations.
### Upcoming Version
- Support for horizontal scaling using Elastic Kubernetes Cluster.
### Release Date
- 2024-03-01

101
install/START_BECKN.md Normal file
View File

@@ -0,0 +1,101 @@
# ONIX Setup Script
## Overview
This shell script, `start_beckn_v2.sh`, automates the setup of Beckn components, including the Registry, Gateway, Protocol Server BAP, Protocol Server BPP, Sandbox, Webhook, and supporting services such as MongoDB, Redis, and RabbitMQ.
## How to Use
1. **Clone the Repository:**
```bash
git clone -b main https://github.com/beckn/onix.git
```
2. **Navigate to the Script Directory:**
```bash
cd onix/install
```
3. **Run the Setup Script:**
```bash
./start_beckn_v2.sh
```
The script will guide you through the installation.
## Installation Sequence - Design
1. **Install Required Packages:**
It will install Docker, Docker-Compose, and jq packages which are required for this setup.
```bash
./package_manager.sh
```
2. **Install Registry Service:**
```bash
./start_container registry
```
3. **Install Gateway Service:**
```bash
./update_gateway_details.sh registry
./start_container gateway
./register_gateway.sh
```
4. **Start Supporting Services:**
- MongoDB
- RabbitMQ
- Redis
```bash
./start_support_services
```
5. **Install Protocol Server for BAP:**
```bash
./update_bap_config.sh
./start_container "bap-client"
./start_container "bap-network"
```
6. **Install Sandbox:**
```bash
./start_container "sandbox-api"
```
7. **Install Webhook:**
```bash
./start_container "sandbox-webhook"
```
8. **Install Protocol Server for BPP:**
```bash
./update_bpp_config.sh
./start_container "bpp-client"
./start_container "bpp-network"
```
## Post-Installation Details
Upon successful execution, the script provides the following details for use in the Postman collection:
For Example
```bash
BASE_URL=http://172.18.0.7:5001/
BAP_ID=bap-network
BAP_URI=http://172.18.0.11:5002/
BPP_ID=bpp-network
BPP_URI=http://172.18.0.12:6002/
```

View File

@@ -0,0 +1,46 @@
version: "3"
services:
mongo_db:
image: mongo
restart: unless-stopped
container_name: mongoDB
volumes:
- ./docker_data/mongo_DB:/data/db
networks:
- beckn_network
ports:
- "27017:27017"
environment:
- MONGO_INITDB_ROOT_USERNAME=beckn
- MONGO_INITDB_ROOT_PASSWORD=beckn123
- MONGO_INITDB_DATABASE=protocol_server
redis_db:
image: redis:6.2.5-alpine
restart: unless-stopped
container_name: redis
networks:
- beckn_network
ports:
- "6379:6379"
volumes:
- ./docker_data/redis_DB:/data
queue_service:
image: rabbitmq:3.9.11-management-alpine
restart: unless-stopped
container_name: rabbitmq
networks:
- beckn_network
ports:
- "5672:5672"
- "15672:15672"
environment:
AMQP_URL: "amqp://queue_service?connection_attempts=3&retry_delay=5"
RABBITMQ_DEFAULT_USER: beckn
RABBITMQ_DEFAULT_PASS: beckn123
networks:
beckn_network:
driver: bridge

View File

@@ -0,0 +1,112 @@
version: '3'
services:
registry:
image: fidedocker/registry
container_name: registry
networks:
- beckn_network
ports:
- 3000:3000
- 3030:3030
restart: unless-stopped
volumes:
- ./registry_data/config/swf.properties:/registry/overrideProperties/config/swf.properties
- ./registry_data/database:/registry/database
gateway:
image: fidedocker/gateway
depends_on:
- registry
container_name: gateway
networks:
- beckn_network
ports:
- 4000:4000
- 4030:4030
restart: unless-stopped
volumes:
- ./gateway_data/config/swf.properties:/gateway/overrideProperties/config/swf.properties
- ./gateway_data/database:/gateway/database
bap-client:
image: fidedocker/protocol-server
container_name: bap-client
networks:
- beckn_network
ports:
- 5001:5001
restart: unless-stopped
volumes:
- ./protocol-server-data/bap-client.yml:/usr/src/app/config/default.yml
bap-network:
image: fidedocker/protocol-server
container_name: bap-network
networks:
- beckn_network
ports:
- 5002:5002
restart: unless-stopped
volumes:
- ./protocol-server-data/bap-network.yml:/usr/src/app/config/default.yml
sandbox-api:
image: fidedocker/sandbox-api
container_name: sandbox-api
networks:
- beckn_network
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
bpp-client:
image: fidedocker/protocol-server
container_name: bpp-client
networks:
- beckn_network
ports:
- 6001:6001
restart: unless-stopped
volumes:
- ./protocol-server-data/bpp-client.yml:/usr/src/app/config/default.yml
bpp-network:
image: fidedocker/protocol-server
container_name: bpp-network
networks:
- beckn_network
ports:
- 6002:6002
restart: unless-stopped
volumes:
- ./protocol-server-data/bpp-network.yml:/usr/src/app/config/default.yml
generic-client-layer:
image: fidedocker/generic-client-layer
container_name: generic-client-layer
networks:
- beckn_network
ports:
- 3015:3000
restart: unless-stopped
volumes:
- ./ENV/.env-generic-client-layer:/app/.env
networks:
beckn_network:
driver: bridge

118
install/docker-compose.yml Normal file
View File

@@ -0,0 +1,118 @@
version: '3'
services:
registry:
image: fidedocker/registry
container_name: registry
networks:
- beckn_network
ports:
- 3000:3000
- 3030:3030
restart: unless-stopped
volumes:
- ./registry_data/config/swf.properties:/registry/overrideProperties/config/swf.properties
- ./registry_data/database:/registry/database
gateway:
image: fidedocker/gateway
depends_on:
- registry
container_name: gateway
networks:
- beckn_network
ports:
- 4000:4000
- 4030:4030
restart: unless-stopped
volumes:
- ./gateway_data/config/swf.properties:/gateway/overrideProperties/config/swf.properties
- ./gateway_data/database:/gateway/database
bap-client:
image: fidedocker/protocol-server
depends_on:
- registry
- gateway
container_name: bap-client
networks:
- beckn_network
ports:
- 5001:5001
restart: unless-stopped
volumes:
- ./protocol-server-data/bap-client.yml:/usr/src/app/config/default.yml
bap-network:
image: fidedocker/protocol-server
depends_on:
- registry
- gateway
container_name: bap-network
networks:
- beckn_network
ports:
- 5002:5002
restart: unless-stopped
volumes:
- ./protocol-server-data/bap-network.yml:/usr/src/app/config/default.yml
sandbox-api:
image: fidedocker/sandbox-api
depends_on:
- registry
- gateway
container_name: sandbox-api
networks:
- beckn_network
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
bpp-client:
image: fidedocker/protocol-server
depends_on:
- registry
- gateway
container_name: bpp-client
networks:
- beckn_network
ports:
- 6001:6001
restart: unless-stopped
volumes:
- ./protocol-server-data/bpp-client.yml:/usr/src/app/config/default.yml
bpp-network:
image: fidedocker/protocol-server
depends_on:
- registry
- gateway
container_name: bpp-network
networks:
- beckn_network
ports:
- 6002:6002
restart: unless-stopped
volumes:
- ./protocol-server-data/bpp-network.yml:/usr/src/app/config/default.yml
networks:
beckn_network:
driver: bridge

View File

@@ -0,0 +1,2 @@
export dport=4000
export wport=4030

View File

@@ -0,0 +1,20 @@
com.venky.core.log.InfoFileHandler.limit=500000
com.venky.core.log.InfoFileHandler.count=2
com.venky.core.log.InfoFileHandler.formatter=java.util.logging.SimpleFormatter
com.venky.core.log.InfoFileHandler.pattern=tmp/java_info%u.log
com.venky.core.log.InfoFileHandler.level=ALL
com.venky.core.log.WarningFileHandler.limit=500000
com.venky.core.log.WarningFileHandler.count=2
com.venky.core.log.WarningFileHandler.formatter=java.util.logging.SimpleFormatter
com.venky.core.log.WarningFileHandler.pattern=tmp/java_warn%u.log
com.venky.core.log.WarningFileHandler.level=WARNING
handlers=com.venky.core.log.WarningFileHandler com.venky.core.log.InfoFileHandler
logger.useParentHandlers=false
.level=INFO
com.venky.swf.plugins.background.core.level=FINEST
com.venky.swf.db.Database.level=FINEST
#com.venky.core.log.TimerStatistics.level=FINE

View File

@@ -0,0 +1,42 @@
swf.load.complete.config.tables.if.count.less.than=500
swf.user.password.encrypted=false
swf.plugins.background.core.workers.numThreads=1
swf.application.authentication.required=false
beckn.network.timeout=10000
#swf.host=localhost
swf.host=GATEWAY_URL
swf.external.port=GATEWAY_PORT
swf.external.scheme=PROTOCOL
swf.jdbc.driver=org.h2.Driver
swf.jdbc.url=jdbc:h2:./database/gateway;AUTO_SERVER=TRUE;
swf.jdbc.userid=gateway
swf.jdbc.password=gateway
swf.jdbc.validationQuery=values(1)
swf.jdbc.dbschema=PUBLIC
swf.jdbc.dbschema.setonconnection=true
swf.jdbc.set.dbschema.command=set schema public
# These keys are needed if you want to in.succinct.beckn.gateway.subscriber_iduse push notifications.
# you can generate this from https://d3v.one/vapid-key-generator/ or similiar sites.
# you also need to specify the public key in src/main/resources/scripts/application.js
#push.server.private.key=your_private_key
#push.server.public.key=your_public_key
## Beckn Gateway configurations.
beckn.auth.enabled=true
in.succinct.beckn.gateway.subscriber_id=SUBSCRIBER_ID
in.succinct.beckn.gateway.public_key_id=SUBSCRIBER_ID.k1
in.succinct.beckn.registry.url=REGISTRY_URL
in.succinct.beckn.registry.signing_public_key=SIGNING_PUBLIC_KEY
in.succinct.beckn.registry.encryption_public_key=ENCRYPTION_PUBLIC_KEY
swf.encryption.support=false
#swf.key.store.directory=./.keystore

View File

@@ -0,0 +1,11 @@
docker_data
gateway_data/config/swf.properties
registry_data/config/swf.properties
.vscode
protocol-server-data/bap-client.yml
protocol-server-data/bap-network.yml
protocol-server-data/bpp-client.yml
protocol-server-data/bpp-network.yml
ENV/.env-generic-client-layer
registry.lock*
gateway.lock*

View File

@@ -0,0 +1,133 @@
# Mandatory
server:
port: BAP_CLIENT_PORT
# Mandatory.
cache:
host: "REDIS_URL"
port: 6379
ttl: "PT10M"
# Optional. Default is 0.
db: 1
# Optional.
responseCache:
mongoURL: "mongodb://MONGO_USERNAME:MONGO_PASSWORD@MONOG_URL/MONGO_DB_NAME?authSource=admin"
ttl: "PT10M"
# Mandatory.
# Priority order will be
# 1. Synchronous
# 2. webhook
# 3. pubSub
client:
synchronous:
mongoURL: "mongodb://MONGO_USERNAME:MONGO_PASSWORD@MONOG_URL/MONGO_DB_NAME?authSource=admin"
#webhook:
# url: "https://beckn.free.beeceptor.com/clientURL"
#messageQueue:
# amqpURL: "amqp://guest:guest@localhost:5672"
# incomingQueue: "protocol-server-incoming"
# outgoingQueue: "protocol-server-outgoing"
# Mandatory.
app:
# Mandatory.
mode: bap
# Two types of gateway mode present.
# client and network.
gateway:
mode: client
inboxQueue: "inbox"
outboxQueue: "outbox"
amqpURL: "amqp://RABBITMQ_USERNAME:RABBITMQ_PASSWORD@RABBITMQ_URL:5672"
# Mandatory.
actions:
requests:
search:
ttl : "PT15S"
init:
ttl : "PT10S"
select:
ttl : "PT10S"
confirm:
ttl : "PT10S"
status:
ttl : "PT10S"
track:
ttl : "PT10S"
cancel:
ttl : "PT10S"
update:
ttl : "PT10S"
rating:
ttl : "PT10S"
support:
ttl : "PT10S"
get_cancellation_reasons:
ttl : "PT10S"
get_rating_categories:
ttl : "PT10S"
cancellation:
ttl : "PT10S"
responses:
on_search:
ttl: "PT15S"
on_init:
ttl: "PT10S"
on_select:
ttl: "PT10S"
on_confirm:
ttl: "PT10S"
on_status:
ttl: "PT10S"
on_track:
ttl: "PT10S"
on_cancel:
ttl: "PT10S"
on_update:
ttl: "PT10S"
on_rating:
ttl: "PT10S"
on_support:
ttl: "PT10S"
cancellation_reasons:
ttl: "PT10S"
rating_categories:
ttl: "PT10S"
# Mandatory.
privateKey: "PRIVATE_KEY"
publicKey: "PUBLIC_KEY"
# Mandatory.
subscriberId: "BAP_SUBSCRIBER_ID"
subscriberUri: "BAP_SUBSCRIBER_URL"
# Mandatory.
registryUrl: REGISTRY_URL
auth: false
uniqueKey: "BAP_SUBSCRIBER_ID_KEY"
# Mandatory.
city: "std:080"
country: "IND"
# Mandatory.
ttl: "PT10M"
# Mandatory.
httpTimeout: "PT3S"
httpRetryCount: 2
telemetry:
enabled: false
url: ""
batchSize: 100
# In minutes
syncInterval: 30
redis_db: 3

View File

@@ -0,0 +1,133 @@
# Mandatory
server:
port: BAP_NETWORK_PORT
# Mandatory.
cache:
host: "REDIS_URL"
port: 6379
ttl: "PT10M"
# Optional. Default is 0.
db: 1
# Optional.
responseCache:
mongoURL: "mongodb://MONGO_USERNAME:MONGO_PASSWORD@MONOG_URL/MONGO_DB_NAME?authSource=admin"
ttl: "PT10M"
# Mandatory.
# Priority order will be
# 1. Synchronous
# 2. webhook
# 3. pubSub
client:
synchronous:
mongoURL: "mongodb://MONGO_USERNAME:MONGO_PASSWORD@MONOG_URL/MONGO_DB_NAME?authSource=admin"
#webhook:
# url: "https://beckn.free.beeceptor.com/clientURL"
#messageQueue:
# amqpURL: "amqp://guest:guest@localhost:5672"
# incomingQueue: "protocol-server-incoming"
# outgoingQueue: "protocol-server-outgoing"
# Mandatory.
app:
# Mandatory.
mode: bap
# Two types of gateway mode present.
# client and network.
gateway:
mode: network
inboxQueue: "inbox"
outboxQueue: "outbox"
amqpURL: "amqp://RABBITMQ_USERNAME:RABBITMQ_PASSWORD@RABBITMQ_URL:5672"
# Mandatory.
actions:
requests:
search:
ttl : "PT15S"
init:
ttl : "PT10S"
select:
ttl : "PT10S"
confirm:
ttl : "PT10S"
status:
ttl : "PT10S"
track:
ttl : "PT10S"
cancel:
ttl : "PT10S"
update:
ttl : "PT10S"
rating:
ttl : "PT10S"
support:
ttl : "PT10S"
get_cancellation_reasons:
ttl : "PT10S"
get_rating_categories:
ttl : "PT10S"
cancellation:
ttl : "PT10S"
responses:
on_search:
ttl: "PT15S"
on_init:
ttl: "PT10S"
on_select:
ttl: "PT10S"
on_confirm:
ttl: "PT10S"
on_status:
ttl: "PT10S"
on_track:
ttl: "PT10S"
on_cancel:
ttl: "PT10S"
on_update:
ttl: "PT10S"
on_rating:
ttl: "PT10S"
on_support:
ttl: "PT10S"
cancellation_reasons:
ttl: "PT10S"
rating_categories:
ttl: "PT10S"
# Mandatory.
privateKey: "PRIVATE_KEY"
publicKey: "PUBLIC_KEY"
# Mandatory.
subscriberId: "BAP_SUBSCRIBER_ID"
subscriberUri: "BAP_SUBSCRIBER_URL"
# Mandatory.
registryUrl: REGISTRY_URL
auth: false
uniqueKey: "BAP_SUBSCRIBER_ID_KEY"
# Mandatory.
city: "std:080"
country: "IND"
# Mandatory.
ttl: "PT10M"
# Mandatory.
httpTimeout: "PT3S"
httpRetryCount: 2
telemetry:
enabled: false
url: ""
batchSize: 100
# In minutes
syncInterval: 30
redis_db: 3

View File

@@ -0,0 +1,131 @@
# Mandatory
server:
port: BPP_CLIENT_PORT
# Mandatory.
cache:
host: "REDIS_URL"
port: 6379
ttl: "PT10M"
# Optional. Default is 0.
db: 0
# Optional.
responseCache:
mongoURL: "mongodb://MONGO_USERNAME:MONGO_PASSWORD@MONOG_URL/MONGO_DB_NAME?authSource=admin"
ttl: "PT10M"
# Mandatory.
# Priority order will be
# 1. Synchronous
# 2. webhook
# 3. pubSub
client:
# synchronous:
# mongoURL: "mongodb://tvast:password@mongoDB:27017/ps?authSource=admin"
webhook:
url: "WEBHOOK_URL"
#messageQueue:
# amqpURL: "amqp://guest:guest@localhost:5672"
# incomingQueue: "protocol-server-incoming"
# outgoingQueue: "protocol-server-outgoing"
# Mandatory.
app:
# Mandatory.
mode: bpp
# Two types of gateway mode present.
# client and network.
gateway:
mode: client
inboxQueue: "inbox-bpp"
outboxQueue: "outbox-bpp"
amqpURL: "amqp://RABBITMQ_USERNAME:RABBITMQ_PASSWORD@RABBITMQ_URL:5672"
# Mandatory.
actions:
requests:
search:
ttl : "PT15S"
init:
ttl : "PT10S"
select:
ttl : "PT10S"
confirm:
ttl : "PT10S"
status:
ttl : "PT10S"
track:
ttl : "PT10S"
cancel:
ttl : "PT10S"
update:
ttl : "PT10S"
rating:
ttl : "PT10S"
support:
ttl : "PT10S"
get_cancellation_reasons:
ttl: "PT10S"
get_rating_categories:
ttl: "PT10S"
responses:
on_search:
ttl: "PT15S"
on_init:
ttl: "PT10S"
on_select:
ttl: "PT10S"
on_confirm:
ttl: "PT10S"
on_status:
ttl: "PT10S"
on_track:
ttl: "PT10S"
on_cancel:
ttl: "PT10S"
on_update:
ttl: "PT10S"
on_rating:
ttl: "PT10S"
on_support:
ttl: "PT10S"
cancellation_reasons:
ttl: "PT10S"
rating_categories:
ttl: "PT10S"
# Mandatory.
privateKey: "PRIVATE_KEY"
publicKey: "PUBLIC_KEY"
# Mandatory.
subscriberId: "BPP_SUBSCRIBER_ID"
subscriberUri: "BPP_SUBSCRIBER_URL"
# Mandatory.
registryUrl: REGISTRY_URL
auth: true
uniqueKey: "BPP_SUBSCRIBER_ID_KEY"
# Mandatory.
city: "std:080"
country: "IND"
# Mandatory.
ttl: "PT10M"
# Mandatory.
httpTimeout: "PT3S"
httpRetryCount: 2
telemetry:
enabled: false
url: ""
batchSize: 100
# In minutes
syncInterval: 30
redis_db: 3

View File

@@ -0,0 +1,131 @@
# Mandatory
server:
port: BPP_NETWORK_PORT
# Mandatory.
cache:
host: "REDIS_URL"
port: 6379
ttl: "PT10M"
# Optional. Default is 0.
db: 0
# Optional.
responseCache:
mongoURL: "mongodb://MONGO_USERNAME:MONGO_PASSWORD@MONOG_URL/MONGO_DB_NAME?authSource=admin"
ttl: "PT10M"
# Mandatory.
# Priority order will be
# 1. Synchronous
# 2. webhook
# 3. pubSub
client:
# synchronous:
# mongoURL: "mongodb://tvast:password@mongoDB:27017/ps?authSource=admin"
webhook:
url: "WEBHOOK_URL"
#messageQueue:
# amqpURL: "amqp://guest:guest@localhost:5672"
# incomingQueue: "protocol-server-incoming"
# outgoingQueue: "protocol-server-outgoing"
# Mandatory.
app:
# Mandatory.
mode: bpp
# Two types of gateway mode present.
# client and network.
gateway:
mode: network
inboxQueue: "inbox-bpp"
outboxQueue: "outbox-bpp"
amqpURL: "amqp://RABBITMQ_USERNAME:RABBITMQ_PASSWORD@RABBITMQ_URL:5672"
# Mandatory.
actions:
requests:
search:
ttl : "PT15S"
init:
ttl : "PT10S"
select:
ttl : "PT10S"
confirm:
ttl : "PT10S"
status:
ttl : "PT10S"
track:
ttl : "PT10S"
cancel:
ttl : "PT10S"
update:
ttl : "PT10S"
rating:
ttl : "PT10S"
support:
ttl : "PT10S"
get_cancellation_reasons:
ttl: "PT10S"
get_rating_categories:
ttl: "PT10S"
responses:
on_search:
ttl: "PT15S"
on_init:
ttl: "PT10S"
on_select:
ttl: "PT10S"
on_confirm:
ttl: "PT10S"
on_status:
ttl: "PT10S"
on_track:
ttl: "PT10S"
on_cancel:
ttl: "PT10S"
on_update:
ttl: "PT10S"
on_rating:
ttl: "PT10S"
on_support:
ttl: "PT10S"
cancellation_reasons:
ttl: "PT10S"
rating_categories:
ttl: "PT10S"
# Mandatory.
privateKey: "PRIVATE_KEY"
publicKey: "PUBLIC_KEY"
# Mandatory.
subscriberId: "BPP_SUBSCRIBER_ID"
subscriberUri: "BPP_SUBSCRIBER_URL"
# Mandatory.
registryUrl: REGISTRY_URL
auth: true
uniqueKey: "BPP_SUBSCRIBER_ID_KEY"
# Mandatory.
city: "std:080"
country: "IND"
# Mandatory.
ttl: "PT10M"
# Mandatory.
httpTimeout: "PT3S"
httpRetryCount: 2
telemetry:
enabled: false
url: ""
batchSize: 100
# In minutes
syncInterval: 30
redis_db: 3

View File

@@ -0,0 +1,2 @@
export dport=3000
export wport=3030

View File

@@ -0,0 +1,20 @@
com.venky.core.log.InfoFileHandler.limit=500000
com.venky.core.log.InfoFileHandler.count=2
com.venky.core.log.InfoFileHandler.formatter=java.util.logging.SimpleFormatter
com.venky.core.log.InfoFileHandler.pattern=tmp/java_info%u.log
com.venky.core.log.InfoFileHandler.level=ALL
com.venky.core.log.WarningFileHandler.limit=500000
com.venky.core.log.WarningFileHandler.count=2
com.venky.core.log.WarningFileHandler.formatter=java.util.logging.SimpleFormatter
com.venky.core.log.WarningFileHandler.pattern=tmp/java_warn%u.log
com.venky.core.log.WarningFileHandler.level=WARNING
handlers=com.venky.core.log.WarningFileHandler com.venky.core.log.InfoFileHandler
logger.useParentHandlers=false
.level=INFO
com.venky.swf.plugins.background.core.level=FINEST
com.venky.swf.db.Database.level=FINEST
#com.venky.core.log.TimerStatistics.level=FINE

View File

@@ -0,0 +1,39 @@
swf.load.complete.config.tables.if.count.less.than=500
swf.user.password.encrypted=false
swf.plugins.background.core.workers.numThreads=1
swf.application.authentication.required=false
#swf.host=localhost
swf.host=REGISTRY_URL
swf.external.port=REGISTRY_PORT
swf.external.scheme=PROTOCOL
swf.jdbc.driver=org.h2.Driver
swf.jdbc.url=jdbc:h2:./database/registry;AUTO_SERVER=TRUE;
swf.jdbc.userid=registry
swf.jdbc.password=registry
swf.jdbc.validationQuery=values(1)
swf.jdbc.dbschema=PUBLIC
swf.jdbc.dbschema.setonconnection=true
swf.jdbc.set.dbschema.command=set schema public
# These keys are needed if you want to use push notifications.
# you can generate this from https://d3v.one/vapid-key-generator/ or similiar sites.
# you also need to specify the public key in src/main/resources/scripts/application.js
#push.server.private.key=your_private_key
#push.server.public.key=your_public_key
swf.api.keys.case=SNAKE
swf.api.root.required=false
swf.encryption.support=false
#swf.key.store.directory=./.keystore
# Needed for Google Login
#swf.GOOGLE.client.id=
#swf.GOOGLE.client.secret=

View File

@@ -0,0 +1,11 @@
docker_data
gateway_data/config/swf.properties
registry_data/config/swf.properties
.vscode
protocol-server-data/bap-client.yml
protocol-server-data/bap-network.yml
protocol-server-data/bpp-client.yml
protocol-server-data/bpp-network.yml
ENV/.env-generic-client-layer
registry.lock*
gateway.lock*

View File

@@ -0,0 +1,45 @@
# Release Notes
## ONIX Version 0.1.0 (2024-02-16)
### Objective
ONIX - Open Network In A Box, is a utility designed to effortlessly set up all BECKN components on a machine using a one-click installer. This tool serves as a valuable resource for developers and network participants eager to explore BECKN protocols or join open networks supported by the BECKN protocol. By simplifying the installation process, ONIX streamlines the onboarding experience.
The current version installs all components automatically without requiring user input, facilitating a seamless setup process. However, we are committed to further enhancing ONIX's functionality. In the upcoming release, we will introduce the capability to selectively install specific components and accommodate user-provided configurations.
For a comprehensive summary of the features, refer [here](https://github.com/beckn/beckn-utilities/milestone/2?closed=1)
Experience the convenience and efficiency of ONIX as you embark on your journey with BECKN protocols and open networks.
### New Features
- Implemented installation support for the following BECKN components:
- Protocol Server BAP
- Protocol Server BPP
- Webhook BPP
- Sandbox
- Registry
- Gateway
- Infrastructure required for the above services
This release is specifically tailored for deployment on Linux machines, encompassing all aforementioned components with default configurations.
### Enhancements
- None
### Bug Fixes
- None
### Known Issues
- None
### Limitations
- The current installer is tested only for Linux (Ubuntu), it might support other flavors also.
- The current version installs all the components with the default configurations.
### Upcoming Version
- Installation of individual components with user-provided configuration.
- Support for Windows and Mac OS will be added.
### Release Date
- 2024-02-16

27
install/scripts/banner.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/variables.sh
# Define the text to print in the banner
text="
###### ####### ##### # # # #
# # # # # # # ## #
# # # # # # # # #
###### ##### # ### # # #
# # # # # # # # #
# # # # # # # # ##
###### ####### ##### # # # #
"
text2="
######## ######## ###### ## ## ## ##
## ## ## ## ## ## ## ### ##
## ## ## ## ## ## #### ##
######## ###### ## ##### ## ## ##
## ## ## ## ## ## ## ####
## ## ## ## ## ## ## ## ###
######## ######## ###### ## ## ## ##
"
# Clear the terminal screen
clear
echo "${GREEN}$text2${NC}"

View File

@@ -0,0 +1,27 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/variables.sh
# Run the script that generates keys and capture the output
get_keys() {
docker pull fidedocker/protocol-server > /dev/null 2>&1
docker run --name temp -itd fidedocker/protocol-server > /dev/null 2>&1
output=$(docker exec -it temp node /usr/src/app/scripts/generate-keys 2>&1)
docker stop temp > /dev/null 2>&1
docker rm temp > /dev/null 2>&1
# Check if the script executed successfully
if [ $? -eq 0 ]; then
# Extract Public Key and Private Key using grep and awk
public_key=$(echo "$output" | awk '/Your Public Key/ {getline; print $0}')
private_key=$(echo "$output" | awk '/Your Private Key/ {getline; print $0}')
# Remove leading and trailing whitespaces
public_key=$(echo "$public_key" | tr -d '[:space:]')
private_key=$(echo "$private_key" | tr -d '[:space:]')
else
# Print an error message if the script failed
echo "${RED}Error: Key generation script failed. Please check the script output.${NC}"
fi
}
#get_keys

View File

@@ -0,0 +1,21 @@
#!/bin/bash
update_env_file(){
cp ../ENV/.env-generic-client-layer-sample ../ENV/.env-generic-client-layer
envFile=../ENV/.env-generic-client-layer
bap_subscriber_id=$1
bap_subscriber_url=$2
bap_client_url=$3
if [[ $(uname) == "Darwin" ]]; then
sed -i '' "s|BAP_SUBSCRIBER_ID|$bap_subscriber_id|" $envFile
sed -i '' "s|BAP_SUBSCRIBER_URL|$bap_subscriber_url|" $envFile
sed -i '' "s|BAP_CLIENT_URL|$bap_client_url|" $envFile
else
sed -i "s|BAP_SUBSCRIBER_ID|$bap_subscriber_id|" $envFile
sed -i "s|BAP_SUBSCRIBER_URL|$bap_subscriber_url|" $envFile
sed -i "s|BAP_CLIENT_URL|$bap_client_url|" $envFile
fi
}
update_env_file $1 $2 $3

View File

@@ -0,0 +1,8 @@
#!/bin/bash
get_container_ip() {
container_name=$1
container_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $container_name)
echo $container_ip
}
#get_container_ip $1

View File

@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: swf-config
data:
swf.properties: |
# Content of swf.properties file for registry

View File

@@ -0,0 +1,59 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: registry-deployment
spec:
replicas: 1
selector:
matchLabels:
app: registry
template:
metadata:
labels:
app: registry
spec:
containers:
- name: registry
image: fidedocker/registry
ports:
- containerPort: 3000
- containerPort: 3030
volumeMounts:
- name: registry-data
mountPath: /registry
volumes:
- name: registry-data
hostPath:
path: /absolute/path/to/registry_data/
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: gateway-deployment
spec:
replicas: 1
selector:
matchLabels:
app: gateway
template:
metadata:
labels:
app: gateway
spec:
containers:
- name: gateway
image: fidedocker/gateway
ports:
- containerPort: 4000
- containerPort: 4030
volumeMounts:
- name: gateway-data
mountPath: /gateway
volumes:
- name: gateway-data
hostPath:
path: /path/to/gateway_data
# Repeat the above structure for other services

View File

@@ -0,0 +1,24 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: beckn-ingress
spec:
rules:
- host: localhost
http:
paths:
- path: /registry
pathType: Prefix
backend:
service:
name: registry-service
port:
number: 3000
- path: /gateway
pathType: Prefix
backend:
service:
name: gateway-service
port:
number: 4000
# Repeat the above structure for other services

View File

@@ -0,0 +1,33 @@
apiVersion: v1
kind: Service
metadata:
name: registry-service
spec:
selector:
app: registry
ports:
- protocol: TCP
port: 3000
targetPort: 3000
- protocol: TCP
port: 3030
targetPort: 3030
---
apiVersion: v1
kind: Service
metadata:
name: gateway-service
spec:
selector:
app: gateway
ports:
- protocol: TCP
port: 4000
targetPort: 4000
- protocol: TCP
port: 4030
targetPort: 4030
# Repeat the above structure for other services

View File

@@ -0,0 +1,152 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/variables.sh
#Required packages list as below.
package_list=("docker" "docker-compose" "jq")
command_exists() {
command -v "$1" &>/dev/null
}
# Redirect input from /dev/null to silence prompts
export DEBIAN_FRONTEND=noninteractive
export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
#Install Package
install_package() {
if [ -x "$(command -v apt-get)" ]; then
# APT (Debian/Ubuntu)
if [ "$1" == "docker" ]; then
docker > /dev/null 2>&1
if [ $? -ne 0 ]; then
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update >/dev/null 2>&1
sudo apt install -y docker-ce docker-ce-cli containerd.io >/dev/null 2>&1
sudo usermod -aG docker $USER
source ~/.bashrc
command_exists docker
if [ $? -eq 0 ]; then
sleep 10
sudo systemctl enable docker.service
sudo systemctl restart docker.service
fi
else
echo "Docker is already installed."
fi
else
if ! dpkg -l | grep -q "^ii $1 "; then
sudo apt-get update >/dev/null 2>&1
sudo apt-get install -y $1 > /dev/null 2>&1
else
echo "$1 is already installed."
fi
fi
elif [ -x "$(command -v yum)" ]; then
# YUM (Red Hat/CentOS)
if [ "$1" == "docker" ]; then
if ! rpm -qa | grep -q docker-ce; then
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker
sudo yum install -y docker >/dev/null 2>&1
sudo systemctl enable docker.service
sudo systemctl start docker.service
sudo usermod -aG docker $USER
source ~/.bashrc
else
echo "Docker is already installed."
fi
else
if ! rpm -qa | grep -q "^$1-"; then
sudo yum install -y $1 >/dev/null 2>&1
else
echo "$1 is already installed."
fi
fi
elif [ -x "$(command -v amazon-linux-extras)" ]; then
# Amazon Linux 2
if ! amazon-linux-extras list | grep -q "^$1 "; then
sudo amazon-linux-extras install $1 >/dev/null 2>&1
else
echo "$1 is already installed."
fi
else
echo "${RED}Unsupported package manager. Please install $1 manually.${NC}"
exit 1
fi
}
remove_package(){
if [ -x "$(command -v apt-get)" ]; then
# APT (Debian/Ubuntu)
sudo apt-get purge -y $1 >/dev/null 2>&1
sudo apt autoremove -y >/dev/null 2>&1
elif [ -x "$(command -v yum)" ]; then
# YUM (Red Hat/CentOS)
sudo yum remove -y $1 >/dev/null 2>&1
sudo yum autoremove -y >/dev/null 2>&1
fi
}
# Function to install Docker
install_docker_bash() {
# Install Docker Bash completion
echo "Installing Docker Bash completion..."
sudo curl -L https://raw.githubusercontent.com/docker/cli/master/contrib/completion/bash/docker -o /etc/bash_completion.d/docker
}
# Function to install Docker Compose
install_docker_compose() {
command_exists docker-compose
if [ $? -eq 0 ]; then
echo "docker-compose is already installed."
return
else
echo "Installing Docker Compose..."
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
fi
# Check if Docker Compose installation was successful
if [ $? -eq 0 ]; then
echo "Docker Compose installed successfully."
else
echo "${RED}Failed to install Docker Compose. Exiting.${NC}"
exit 1
fi
if [ -f /etc/bash_completion.d/docker-compose ]; then
echo "Docker Compose Bash completion is already installed."
else
# Install Docker Compose Bash completion
echo "Installing Docker Compose Bash completion..."
sudo curl -L https://raw.githubusercontent.com/docker/compose/master/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
fi
}
# Check if package is already installed
for package in "${package_list[@]}"; do
if ! command_exists $package; then
install_package "$package"
fi
if [ "$package" == "docker" ]; then
if [[ $(uname -s ) == 'Linux' ]];then
if [ -f /etc/bash_completion.d/docker ]; then
echo "Docker Bash completion is already installed."
else
install_docker_bash
fi
fi
fi
if [ "$package" == "docker-compose" ]; then
if [[ $(uname -s ) == 'Linux' ]];then
install_docker_compose
fi
fi
done

View File

@@ -0,0 +1,32 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/get_container_details.sh
register_gw() {
cookie_file="cookies.txt"
# Step 1: Perform login and save the session cookies to a file
curl --cookie-jar $cookie_file --request POST $login_url
curl --request GET --cookie $cookie_file $subscribe_url
rm -rf $cookie_file
}
if [[ $(uname -s) == 'Darwin' ]]; then
ip=localhost
elif [[ $(systemd-detect-virt) == 'wsl' ]]; then
ip=$(hostname -I | awk '{print $1}')
else
ip=$(get_container_ip gateway)
fi
if [[ $1 ]]; then
if [[ $1 == https://* ]]; then
login_url="$1/login?name=root&password=root&_LOGIN=Login"
subscribe_url="$1/bg/subscribe"
register_gw
fi
else
login_url="http://$ip:4030/login?name=root&password=root&_LOGIN=Login"
subscribe_url="http://$ip:4030/bg/subscribe"
register_gw
fi

View File

@@ -0,0 +1,44 @@
#!/bin/bash
source $SCRIPT_DIR/variables.sh
create_network_participant() {
# Set your variables
registry_url="$1"
content_type="$2"
subscriber_id="$3"
pub_key_id="$4"
subscriber_url="$5"
encr_public_key="$6"
signing_public_key="$7"
valid_from="$8"
valid_until="$9"
type="${10}"
json_data=$(cat <<EOF
{
"subscriber_id": "$subscriber_id",
"pub_key_id": "$pub_key_id",
"subscriber_url": "$subscriber_url",
"domain": " ",
"encr_public_key": "$encr_public_key",
"signing_public_key": "$signing_public_key",
"valid_from": "$valid_from",
"valid_until": "$valid_until",
"type": "$type",
"country": "IND",
"status": "SUBSCRIBED"
}
EOF
)
response=$(curl --location --request POST "$registry_url/register" \
--header "Content-Type: $content_type" \
--data-raw "$json_data" 2>&1)
if [ $? -eq 0 ]; then
echo "${GREEN}Network Participant Entry is created. Please login to registry $registry_url and subscribe you Network Participant.${NC}"
else
echo "${RED}Error: $response${NC}"
fi
}

View File

@@ -0,0 +1,124 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/registry_entry.sh
source $SCRIPT_DIR/generate_keys.sh
source $SCRIPT_DIR/variables.sh
source $SCRIPT_DIR/get_container_details.sh
newClientFile=$(echo "$bapClientFile" | sed 's/yaml-sample/yml/')
newNetworkFile=$(echo "$bapNetworkFile" | sed 's/yaml-sample/yml/')
cp $bapClientFile $newClientFile
cp $bapNetworkFile $newNetworkFile
clientFile=$newClientFile
networkFile=$newNetworkFile
client_port=$bap_client_port
network_port=$bap_network_port
if [[ $(uname) == "Darwin" ]]; then
sed -i '' "s|BAP_NETWORK_PORT|$network_port|" $networkFile
sed -i '' "s|BAP_CLIENT_PORT|$client_port|" $clientFile
else
sed -i "s|BAP_NETWORK_PORT|$network_port|" $networkFile
sed -i "s|BAP_CLIENT_PORT|$client_port|" $clientFile
fi
if [[ $1 ]]; then
registry_url=$1
bap_subscriber_id=$2
bap_subscriber_id_key=$3
bap_subscriber_url=$4
else
if [[ $(uname -s) == 'Darwin' ]]; then
ip=localhost
registry_url="http://$ip:3030/subscribers"
elif [[ $(systemd-detect-virt) == 'wsl' ]]; then
ip=$(hostname -I | awk '{print $1}')
registry_url="http://$ip:3030/subscribers"
else
registry_url="http://$(get_container_ip registry):3030/subscribers"
fi
fi
echo "Generating public/private key pair"
get_keys
echo "Your Private Key: $private_key"
echo "Your Public Key: $public_key"
valid_from=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")
if [[ $(uname -s ) == 'Darwin' ]];then
valid_from=$(date -u +"%Y-%m-%dT%H:%M:%S.%000Z")
valid_until=$(date -u -v+1y +"%Y-%m-%dT%H:%M:%S.%000Z")
else
valid_from=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")
valid_until=$(date -u -d "+1 year" +"%Y-%m-%dT%H:%M:%S.%3NZ")
fi
type=BAP
# Define an associative array for replacements
if [[ $(uname -s ) == 'Darwin' ]];then
replacements=(
"REDIS_URL=$redisUrl"
"REGISTRY_URL=$registry_url"
"MONGO_USERNAME=$mongo_initdb_root_username"
"MONGO_PASSWORD=$mongo_initdb_root_password"
"MONGO_DB_NAME=$mongo_initdb_database"
"MONOG_URL=$mongoUrl"
"RABBITMQ_USERNAME=$rabbitmq_default_user"
"RABBITMQ_PASSWORD=$rabbitmq_default_pass"
"RABBITMQ_URL=$rabbitmqUrl"
"PRIVATE_KEY=$private_key"
"PUBLIC_KEY=$public_key"
"BAP_SUBSCRIBER_ID=$bap_subscriber_id"
"BAP_SUBSCRIBER_URL=$bap_subscriber_url"
"BAP_SUBSCRIBER_ID_KEY=$bap_subscriber_id_key"
)
echo "Configuring BAP protocol server"
# Apply replacements in both files
for file in "$clientFile" "$networkFile"; do
for line in "${replacements[@]}"; do
key=$(echo "$line" | cut -d '=' -f1)
value=$(echo "$line" | cut -d '=' -f2)
sed -i '' "s|$key|$value|" "$file"
done
done
else
declare -A replacements=(
["REDIS_URL"]=$redisUrl
["REGISTRY_URL"]=$registry_url
["MONGO_USERNAME"]=$mongo_initdb_root_username
["MONGO_PASSWORD"]=$mongo_initdb_root_password
["MONGO_DB_NAME"]=$mongo_initdb_database
["MONOG_URL"]=$mongoUrl
["RABBITMQ_USERNAME"]=$rabbitmq_default_user
["RABBITMQ_PASSWORD"]=$rabbitmq_default_pass
["RABBITMQ_URL"]=$rabbitmqUrl
["PRIVATE_KEY"]=$private_key
["PUBLIC_KEY"]=$public_key
["BAP_SUBSCRIBER_ID"]=$bap_subscriber_id
["BAP_SUBSCRIBER_URL"]=$bap_subscriber_url
["BAP_SUBSCRIBER_ID_KEY"]=$bap_subscriber_id_key
)
echo "Configuring BAP protocol server"
# Apply replacements in both files
for file in "$clientFile" "$networkFile"; do
for key in "${!replacements[@]}"; do
sed -i "s|$key|${replacements[$key]}|" "$file"
done
done
fi
echo "Registering BAP protocol server on the registry"
create_network_participant "$registry_url" "application/json" "$bap_subscriber_id" "$bap_subscriber_id_key" "$bap_subscriber_url" "$public_key" "$public_key" "$valid_from" "$valid_until" "$type"

View File

@@ -0,0 +1,124 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/registry_entry.sh
source $SCRIPT_DIR/generate_keys.sh
source $SCRIPT_DIR/variables.sh
source $SCRIPT_DIR/get_container_details.sh
newClientFile=$(echo "$bppClientFile" | sed 's/yaml-sample/yml/')
newNetworkFile=$(echo "$bppNetworkFile" | sed 's/yaml-sample/yml/')
cp $bppClientFile $newClientFile
cp $bppNetworkFile $newNetworkFile
clientFile=$newClientFile
networkFile=$newNetworkFile
client_port=$bpp_client_port
network_port=$bpp_network_port
if [[ $(uname) == "Darwin" ]]; then
sed -i '' "s|BPP_NETWORK_PORT|$network_port|" $networkFile
sed -i '' "s|BPP_CLIENT_PORT|$client_port|" $clientFile
else
sed -i "s|BPP_NETWORK_PORT|$network_port|" $networkFile
sed -i "s|BPP_CLIENT_PORT|$client_port|" $clientFile
fi
if [[ $1 ]]; then
registry_url=$1
bpp_subscriber_id=$2
bpp_subscriber_id_key=$3
bpp_subscriber_url=$4
else
if [[ $(uname -s) == 'Darwin' ]]; then
ip=localhost
registry_url="http://$ip:3030/subscribers"
elif [[ $(systemd-detect-virt) == 'wsl' ]]; then
ip=$(hostname -I | awk '{print $1}')
registry_url="http://$ip:3030/subscribers"
else
registry_url="http://$(get_container_ip registry):3030/subscribers"
fi
fi
echo "Generating public/private key pair"
get_keys
#echo "Your Private Key: $private_key"
#echo "Your Public Key: $public_key"
if [[ $(uname -s ) == 'Darwin' ]];then
valid_from=$(date -u +"%Y-%m-%dT%H:%M:%S.%000Z")
valid_until=$(date -u -v+1y +"%Y-%m-%dT%H:%M:%S.%000Z")
else
valid_from=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")
valid_until=$(date -u -d "+1 year" +"%Y-%m-%dT%H:%M:%S.%3NZ")
fi
type=BPP
# Define an associative array for replacements
if [[ $(uname -s ) == 'Darwin' ]];then
replacements=(
"REDIS_URL=$redisUrl"
"REGISTRY_URL=$registry_url"
"MONGO_USERNAME=$mongo_initdb_root_username"
"MONGO_PASSWORD=$mongo_initdb_root_password"
"MONGO_DB_NAME=$mongo_initdb_database"
"MONOG_URL=$mongoUrl"
"RABBITMQ_USERNAME=$rabbitmq_default_user"
"RABBITMQ_PASSWORD=$rabbitmq_default_pass"
"RABBITMQ_URL=$rabbitmqUrl"
"PRIVATE_KEY=$private_key"
"PUBLIC_KEY=$public_key"
"BPP_SUBSCRIBER_URL=$bpp_subscriber_url"
"BPP_SUBSCRIBER_ID=$bpp_subscriber_id"
"BPP_SUBSCRIBER_ID_KEY=$bpp_subscriber_id_key"
"WEBHOOK_URL=$webhook_url"
)
echo "Configuring BPP protocol server"
# Apply replacements in both files
for file in "$clientFile" "$networkFile"; do
for line in "${replacements[@]}"; do
key=$(echo "$line" | cut -d '=' -f1)
value=$(echo "$line" | cut -d '=' -f2)
sed -i '' "s|$key|$value|" "$file"
done
done
else
declare -A replacements=(
["REDIS_URL"]=$redisUrl
["REGISTRY_URL"]=$registry_url
["MONGO_USERNAME"]=$mongo_initdb_root_username
["MONGO_PASSWORD"]=$mongo_initdb_root_password
["MONGO_DB_NAME"]=$mongo_initdb_database
["MONOG_URL"]=$mongoUrl
["RABBITMQ_USERNAME"]=$rabbitmq_default_user
["RABBITMQ_PASSWORD"]=$rabbitmq_default_pass
["RABBITMQ_URL"]=$rabbitmqUrl
["PRIVATE_KEY"]=$private_key
["PUBLIC_KEY"]=$public_key
["BPP_SUBSCRIBER_URL"]=$bpp_subscriber_url
["BPP_SUBSCRIBER_ID"]=$bpp_subscriber_id
["BPP_SUBSCRIBER_ID_KEY"]=$bpp_subscriber_id_key
["WEBHOOK_URL"]=$webhook_url
)
echo "Configuring BAP protocol server"
# Apply replacements in both files
for file in "$clientFile" "$networkFile"; do
for key in "${!replacements[@]}"; do
sed -i "s|$key|${replacements[$key]}|" "$file"
done
done
fi
echo "Registering BPP protocol server on the registry"
create_network_participant "$registry_url" "application/json" "$bpp_subscriber_id" "$bpp_subscriber_id_key" "$bpp_subscriber_url" "$public_key" "$public_key" "$valid_from" "$valid_until" "$type"

View File

@@ -0,0 +1,82 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/get_container_details.sh
gateway_url=gateway
gateway_port=4030
protocol=http
reg_url=http://$1:3030/subscribers/lookup
get_details_registry() {
# Make the curl request and store the output in a variable
response=$(curl --location --request POST "$reg_url" \
--header 'Content-Type: application/json' \
--data-raw '{
"type": "LREG"
}')
# Check if the curl command was successful (HTTP status code 2xx)
if [ $? -eq 0 ]; then
# Extract signing_public_key and encr_public_key using jq
signing_public_key=$(echo "$response" | jq -r '.[0].signing_public_key')
encr_public_key=$(echo "$response" | jq -r '.[0].encr_public_key')
subscriber_url=$(echo "$response" | jq -r '.[0].subscriber_url')
else
echo "Error: Unable to fetch data from the server."
fi
}
update_gateway_config() {
# Print the extracted keys
echo "Signing Public Key: $signing_public_key"
echo "Encryption Public Key: $encr_public_key"
echo "URL $subscriber_url"
cp $SCRIPT_DIR/../gateway_data/config/swf.properties-sample $SCRIPT_DIR/../gateway_data/config/swf.properties
config_file="$SCRIPT_DIR/../gateway_data/config/swf.properties"
tmp_file=$(mktemp "tempfile.XXXXXXXXXX")
sed " s|SUBSCRIBER_ID|$gateway_url|g; s|SIGNING_PUBLIC_KEY|$signing_public_key|g; s|ENCRYPTION_PUBLIC_KEY|$encr_public_key|g; s|GATEWAY_URL|$gateway_url|g; s|GATEWAY_PORT|$gateway_port|g; s|PROTOCOL|$protocol|g; s|REGISTRY_URL|$subscriber_url|g" "$config_file" > "$tmp_file"
mv "$tmp_file" "$config_file"
}
if [[ $1 == https://* ]]; then
reg_url=$1/subscribers/lookup
get_details_registry $reg_url
else
service_name=$1
if [[ $(uname -s) == 'Darwin' ]]; then
ip=localhost
elif [[ $(systemd-detect-virt) == 'wsl' ]]; then
ip=$(hostname -I | awk '{print $1}')
else
ip=$(get_container_ip $service_name)
fi
reg_url=http://$ip:3030/subscribers/lookup
get_details_registry $reg_url
fi
if [[ $2 ]]; then
if [[ $2 == https://* ]]; then
if [[ $(uname -s) == 'Darwin' ]]; then
gateway_url=$(echo "$2" | sed -E 's/https:\/\///')
else
gateway_url=$(echo "$2" | sed 's/https:\/\///')
fi
gateway_port=443
protocol=https
update_gateway_config
elif [[ $2 == http://* ]]; then
if [[ $(uname -s) == 'Darwin' ]]; then
gateway_url=$(echo "$2" | sed -E 's/http:\/\///')
else
gateway_url=$(echo "$2" | sed 's/http:\/\///')
fi
gateway_port=80
protocol=http
update_gateway_config
fi
else
update_gateway_config
fi

53
install/scripts/variables.sh Executable file
View File

@@ -0,0 +1,53 @@
#!/bin/bash
#Colour Code
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
NC=$(tput sgr0)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#Comman Variables with Default values
mongo_initdb_root_username="beckn"
mongo_initdb_root_password="beckn123"
mongo_initdb_database="protocol_server"
mongoUrl="mongoDB:27017"
rabbitmq_default_user="beckn"
rabbitmq_default_pass="beckn123"
rabbitmqUrl="rabbitmq"
redisUrl="redis"
registry_url="http://registry:3030/subscribers"
beckn_registry_url="https://registry.becknprotocol.io/subscribers"
#public_key="KKHOpMKQCbJHzjme+CPKI3HQxIhzKMpcLLRGMhzf7rk="
#private_key="W7HkCMPWvxv6/jWqHlyUI4vWX8704+rN3kCwBGIA7rcooc6kwpAJskfOOZ74I8ojcdDEiHMoylwstEYyHN/uuQ=="
#BAP varibales.
bapClientFile="$SCRIPT_DIR/../protocol-server-data/bap-client.yaml-sample"
bapNetworkFile="$SCRIPT_DIR/../protocol-server-data/bap-network.yaml-sample"
bap_client_port=5001
bap_network_port=5002
bap_subscriber_id="bap-network"
bap_subscriber_id_key="bap-network-key"
bap_subscriber_url="http://bap-network:5002"
bap_client_url="http://bap-client:5002"
#BPP varibales.
bppClientFile="$SCRIPT_DIR/../protocol-server-data/bpp-client.yaml-sample"
bppNetworkFile="$SCRIPT_DIR/../protocol-server-data/bpp-network.yaml-sample"
bpp_client_port=6001
bpp_network_port=6002
bpp_subscriber_id="bpp-network"
bpp_subscriber_id_key="bpp-network-key"
bpp_subscriber_url="http://bpp-network:6002"
webhook_url="http://sandbox-webhook:3005"

117
install/start_beckn.sh Executable file
View File

@@ -0,0 +1,117 @@
#!/bin/bash
source ./scripts/variables.sh
source ./scripts/get_container_details.sh
#below function will start specifice service inside docker-compose file
start_container(){
echo "$1"
docker-compose up -d $1
}
#below function will start the MongoDB, Redis and RabbitMQ Services.
start_support_services(){
echo "${GREEN}................Installing MongoDB................${NC}"
docker-compose -f docker-compose-app.yml up -d mongo_db
echo "MongoDB installation successful"
echo "${GREEN}................Installing RabbitMQ................${NC}"
docker-compose -f docker-compose-app.yml up -d queue_service
echo "RabbitMQ installation successful"
echo "${GREEN}................Installing Redis................${NC}"
docker-compose -f docker-compose-app.yml up -d redis_db
echo "Redis installation successful"
}
# Main script starts here
text="
Welcome to ONIX!
The following components will be installed
1. MongoDB, RabbitMQ and Redis
2. Registry
3. Gateway
4. Sandbox
5. Sandbox Webhook
6. Protocol Server for BAP
7. Protocol Server for BPP
"
echo "$text"
sleep 5
echo "${GREEN}................Installing required packages................${NC}"
./scripts/package_manager.sh
echo "Package Installation is done"
export COMPOSE_IGNORE_ORPHANS=1
echo "${GREEN}................Installing Registry service................${NC}"
start_container registry
sleep 10
echo "Registry installation successful"
sleep 5
./scripts/update_gateway_details.sh registry
echo "${GREEN}................Installing Gateway service................${NC}"
start_container gateway
echo "Registering Gateway in the registry"
sleep 5
./scripts/register_gateway.sh
echo " "
echo "Gateway installation successful"
#Start the MongoDB, Redis and RabbitMQ Services.
start_support_services
sleep 10
echo "${GREEN}................Installing Protocol Server for BAP................${NC}"
./scripts/update_bap_config.sh
sleep 10
start_container "bap-client"
start_container "bap-network"
sleep 10
echo "Protocol server BAP installation successful"
echo "${GREEN}................Installing Sandbox................${NC}"
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
start_container "bpp-client"
start_container "bpp-network"
sleep 10
echo "Protocol server BPP installation successful"
if [[ $(uname -s) == 'Darwin' ]]; then
ip=localhost
bap_network_ip=$ip
bap_client_ip=$ip
bpp_network_ip=$ip
bap_network_ip=$ip
elif [[ $(systemd-detect-virt) == 'wsl' ]]; then
ip=$(hostname -I | awk '{print $1}')
bap_network_ip=$ip
bap_client_ip=$ip
bpp_network_ip=$ip
bap_network_ip=$ip
else
bap_network_ip=$(get_container_ip bap-network)
bap_client_ip=$(get_container_ip bap-client)
bpp_network_ip=$(get_container_ip bpp-network)
bap_network_ip=$(get_container_ip bpp-client)
fi
echo " "
echo "##########################################################"
echo "${GREEN}Please find below details of protocol server which required in postman collection${NC}"
echo "BASE_URL=http://$bap_client_ip:$bap_client_port/"
echo "BAP_ID=$bap_subscriber_id"
echo "BAP_URI=http://$bap_network_ip:$bap_network_port/"
echo "BPP_ID=$bpp_subscriber_id"
echo "BPP_URI=http://$bpp_network_ip:$bpp_network_port/"

296
install/start_beckn_v2.sh Executable file
View File

@@ -0,0 +1,296 @@
#!/bin/bash
source scripts/variables.sh
source scripts/get_container_details.sh
# Function to start a specific service inside docker-compose file
install_package(){
echo "${GREEN}................Installing required packages................${NC}"
bash scripts/package_manager.sh
echo "Package Installation is done"
}
start_container(){
#ignore orphaned containers warning
export COMPOSE_IGNORE_ORPHANS=1
docker-compose -f docker-compose-v2.yml up -d $1
}
update_registry_details() {
if [[ $1 ]];then
if [[ $1 == https://* ]]; then
if [[ $(uname -s) == 'Darwin' ]]; then
registry_url=$(echo "$1" | sed -E 's/https:\/\///')
else
registry_url=$(echo "$1" | sed 's/https:\/\///')
fi
registry_port=443
protocol=https
elif [[ $1 == http://* ]]; then
if [[ $(uname -s) == 'Darwin' ]]; then
registry_url=$(echo "$1" | sed -E 's/http:\/\///')
else
registry_url=$(echo "$1" | sed 's/http:\/\///')
fi
registry_port=80
protocol=http
fi
else
registry_url=registry
registry_port=3030
protocol=http
fi
echo $registry_url
cp $SCRIPT_DIR/../registry_data/config/swf.properties-sample $SCRIPT_DIR/../registry_data/config/swf.properties
config_file="$SCRIPT_DIR/../registry_data/config/swf.properties"
tmp_file=$(mktemp "tempfile.XXXXXXXXXX")
sed "s|REGISTRY_URL|$registry_url|g; s|REGISTRY_PORT|$registry_port|g; s|PROTOCOL|$protocol|g" "$config_file" > "$tmp_file"
mv "$tmp_file" "$config_file"
}
# Function to start the MongoDB, Redis, and RabbitMQ Services
start_support_services(){
#ignore orphaned containers warning
export COMPOSE_IGNORE_ORPHANS=1
echo "${GREEN}................Installing MongoDB................${NC}"
docker-compose -f docker-compose-app.yml up -d mongo_db
echo "MongoDB installation successful"
echo "${GREEN}................Installing RabbitMQ................${NC}"
docker-compose -f docker-compose-app.yml up -d queue_service
echo "RabbitMQ installation successful"
echo "${GREEN}................Installing Redis................${NC}"
docker-compose -f docker-compose-app.yml up -d redis_db
echo "Redis installation successful"
}
install_gateway() {
if [[ $1 && $2 ]]; then
bash scripts/update_gateway_details.sh $1 $2
else
bash scripts/update_gateway_details.sh registry
fi
echo "${GREEN}................Installing Gateway service................${NC}"
start_container gateway
echo "Registering Gateway in the registry"
sleep 10
if [[ $1 && $2 ]]; then
bash scripts/register_gateway.sh $2
else
bash scripts/register_gateway.sh
fi
echo " "
echo "Gateway installation successful"
}
# Function to install Beckn Gateway and Beckn Registry
install_registry(){
if [[ $1 ]]; then
update_registry_details $1
else
update_registry_details
fi
echo "${GREEN}................Installing Registry service................${NC}"
start_container registry
sleep 10
echo "Registry installation successful"
}
# Function to install BAP Protocol Server
install_bap_protocol_server(){
start_support_services
if [[ $1 ]];then
registry_url=$1
bap_subscriber_id=$2
bap_subscriber_id_key=$3
bap_subscriber_url=$4
bash scripts/update_bap_config.sh $registry_url $bap_subscriber_id $bap_subscriber_id_key $bap_subscriber_url
else
bash scripts/update_bap_config.sh
fi
sleep 10
start_container "bap-client"
start_container "bap-network"
sleep 10
echo "Protocol server BAP installation successful"
}
# Function to install BPP Protocol Server with BPP Sandbox
install_bpp_protocol_server_with_sandbox(){
start_support_services
echo "${GREEN}................Installing Sandbox................${NC}"
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}"
if [[ $1 ]];then
registry_url=$1
bpp_subscriber_id=$2
bpp_subscriber_id_key=$3
bpp_subscriber_url=$4
bash scripts/update_bpp_config.sh $registry_url $bpp_subscriber_id $bpp_subscriber_id_key $bpp_subscriber_url
else
bash scripts/update_bpp_config.sh
fi
sleep 10
start_container "bpp-client"
start_container "bpp-network"
sleep 10
echo "Protocol server BPP installation successful"
}
# Function to install BPP Protocol Server without Sandbox
install_bpp_protocol_server(){
start_support_services
echo "${GREEN}................Installing Protocol Server for BPP................${NC}"
if [[ $1 ]];then
registry_url=$1
bpp_subscriber_id=$2
bpp_subscriber_id_key=$3
bpp_subscriber_url=$4
webhook_url=$5
bash scripts/update_bpp_config.sh $registry_url $bpp_subscriber_id $bpp_subscriber_id_key $bpp_subscriber_url $$webhook_url
else
bash scripts/update_bpp_config.sh
fi
sleep 10
start_container "bpp-client"
start_container "bpp-network"
sleep 10
echo "Protocol server BPP installation successful"
}
text="
The following components will be installed
1. Registry
2. Gateway
3. Sandbox
4. Sandbox Webhook
5. Protocol Server for BAP
6. Protocol Server for BPP
"
# Main script starts here
bash scripts/banner.sh
echo "Welcome to ONIX"
echo "$text"
read -p "${GREEN}Do you want to install all the components on the local system? (Y/n): ${NC}" install_all
if [[ $install_all =~ ^[Yy]$ ]]; then
# Install and bring up everything
install_package
install_registry
install_gateway
start_support_services
install_bap_protocol_server
install_bpp_protocol_server_with_sandbox
else
# User selects specific components to install
echo "Please select the components that you want to install"
echo "1. Beckn Gateway & Beckn Registry"
echo "2. BAP Protocol Server"
echo "3. BPP Protocol Server with BPP Sandbox"
echo "4. BPP Protocol Server"
echo "5. Generic Client Layer"
echo "6. Exit"
read -p "Enter your choice (1-6): " user_choice
case $user_choice in
1)
echo "${GREEN}Default Registry URL: $registry_url"
echo "Default Gateway URL will be docker URL"
read -p "Do you want to change Registry and Gateway URL? (Y/N): ${NC}" change_url
if [[ $change_url =~ ^[Yy]$ ]]; then
read -p "Enter publicly accessible registry URL: " registry_url
read -p "Enter publicly accessible gateway URL: " gateway_url
if [[ $registry_url =~ /$ ]]; then
new_registry_url=${registry_url%/}
else
new_registry_url=$registry_url
fi
if [[ $gateway_url =~ /$ ]]; then
gateway_url=${gateway_url%/}
fi
install_package
install_registry $new_registry_url
install_gateway $new_registry_url $gateway_url
else
install_package
install_registry
install_gateway
fi
;;
2)
echo "${GREEN}................Installing Protocol Server for BAP................${NC}"
read -p "Enter BAP Subscriber ID: " bap_subscriber_id
read -p "Enter BAP Subscriber URL: " bap_subscriber_url
# Ask the user if they want to change the registry_url
read -p "Do you want to change the registry_url? (${GREEN}Press Enter to accept default: $beckn_registry_url${NC}): " custom_registry_url
registry_url=${custom_registry_url:-$beckn_registry_url}
bap_subscriber_id_key=$bap_subscriber_id-key
install_package
install_bap_protocol_server $registry_url $bap_subscriber_id $bap_subscriber_id_key $bap_subscriber_url
;;
3)
read -p "Enter BPP Subscriber ID: " bpp_subscriber_id
read -p "Enter BPP Subscriber URL: " bpp_subscriber_url
# Ask the user if they want to change the registry_url
read -p "Do you want to change the registry_url? (${GREEN}Press Enter to accept default: $beckn_registry_url${NC}): " custom_registry_url
registry_url=${custom_registry_url:-$beckn_registry_url}
bpp_subscriber_id_key=$bpp_subscriber_id-key
install_package
install_bpp_protocol_server_with_sandbox $registry_url $bpp_subscriber_id $bpp_subscriber_id_key $bpp_subscriber_url
;;
4)
read -p "Enter BPP Subscriber ID: " bpp_subscriber_id
read -p "Enter BPP Subscriber URL: " bpp_subscriber_url
read -p "Enter Webhook URL: " webhook_url
# Ask the user if they want to change the registry_url
read -p "Do you want to change the registry_url? (${GREEN}Press Enter to accept default: $beckn_registry_url${NC}): " custom_registry_url
registry_url=${custom_registry_url:-$beckn_registry_url}
bpp_subscriber_id_key=$bpp_subscriber_id-key
install_package
install_bpp_protocol_server $registry_url $bpp_subscriber_id $bpp_subscriber_id_key $bpp_subscriber_url $webhook_url
;;
5)
echo "${GREEN}................Installing GENERIC CLIENT LAYER................${NC}"
read -p "Enter BAP Subscriber ID: " bap_subscriber_id
read -p "Enter BAP Subscriber URL: " bap_subscriber_url
read -p "Enter BAP Client URL: " bap_client_url
bash scripts/generic-client-layer.sh $bap_subscriber_id $bap_subscriber_url $bap_client_url
start_container "generic-client-layer"
;;
6)
echo "Exiting ONIX"
exit 0
;;
*)
echo "Invalid choice. Exiting ONIX."
exit 1
;;
esac
fi