Initialized empty repo with essential files and folders
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
#!/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}"
|
||||
@@ -1,27 +0,0 @@
|
||||
#!/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 -i 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
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/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
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/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
|
||||
@@ -1,7 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: swf-config
|
||||
data:
|
||||
swf.properties: |
|
||||
# Content of swf.properties file for registry
|
||||
@@ -1,59 +0,0 @@
|
||||
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
|
||||
@@ -1,24 +0,0 @@
|
||||
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
|
||||
@@ -1,33 +0,0 @@
|
||||
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
|
||||
@@ -1,172 +0,0 @@
|
||||
#!/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
|
||||
if ! docker --version > /dev/null 2>&1; then
|
||||
if [ -f /etc/debian_version ]; then
|
||||
curl -fsSL https://download.docker.com/linux/debian/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/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
else
|
||||
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
|
||||
fi
|
||||
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
|
||||
sudo systemctl enable docker.service
|
||||
sudo systemctl restart docker.service
|
||||
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/Amazon Linux)
|
||||
if [ "$1" == "docker" ]; then
|
||||
if ! docker --version > /dev/null 2>&1; then
|
||||
if [ -f /etc/centos-release ]; then
|
||||
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||
elif grep -q "Amazon Linux release 2" /etc/system-release; then
|
||||
sudo amazon-linux-extras install docker -y
|
||||
elif grep -q "Amazon Linux release" /etc/system-release; then
|
||||
sudo yum install -y docker
|
||||
fi
|
||||
sudo yum install -y docker-ce docker-ce-cli containerd.io >/dev/null 2>&1
|
||||
sudo usermod -aG docker $USER
|
||||
source ~/.bashrc
|
||||
sudo systemctl enable docker.service
|
||||
sudo systemctl restart docker.service
|
||||
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 specific
|
||||
if [ "$1" == "docker" ]; then
|
||||
if ! docker --version > /dev/null 2>&1; then
|
||||
sudo amazon-linux-extras install docker -y >/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 ! amazon-linux-extras list | grep -q "$1"; then
|
||||
sudo amazon-linux-extras install $1 -y >/dev/null 2>&1
|
||||
else
|
||||
echo "$1 is already installed."
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Unsupported package manager. Please install $1 manually."
|
||||
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
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/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
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/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",
|
||||
"unique_key_id": "$pub_key_id",
|
||||
"subscriber_url": "$subscriber_url",
|
||||
"domain": " ",
|
||||
"extended_attributes": {"domains": []},
|
||||
"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
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
#!/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_key_id=$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"
|
||||
|
||||
|
||||
if [[ $(uname -s ) == 'Darwin' ]];then
|
||||
valid_from=$(date -u -v-1d +"%Y-%m-%dT%H:%M:%S.%000Z")
|
||||
valid_until=$(date -u -v+3y +"%Y-%m-%dT%H:%M:%S.%000Z")
|
||||
else
|
||||
valid_from=$(date -u -d "-1 day" +"%Y-%m-%dT%H:%M:%S.%3NZ")
|
||||
valid_until=$(date -u -d "+3 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_KEY_ID=$bap_subscriber_key_id"
|
||||
"USE_LAYER_2_CONFIG"=true
|
||||
"MANDATE_LAYER_2_CONFIG"=true
|
||||
)
|
||||
|
||||
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_KEY_ID"]=$bap_subscriber_key_id
|
||||
["USE_LAYER_2_CONFIG"]=true
|
||||
["MANDATE_LAYER_2_CONFIG"]=true
|
||||
)
|
||||
|
||||
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_key_id" "$bap_subscriber_url" "$public_key" "$public_key" "$valid_from" "$valid_until" "$type"
|
||||
@@ -1,132 +0,0 @@
|
||||
#!/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_key_id=$3
|
||||
bpp_subscriber_url=$4
|
||||
webhook_url=$5
|
||||
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 -v-1d +"%Y-%m-%dT%H:%M:%S.%000Z")
|
||||
valid_until=$(date -u -v+3y +"%Y-%m-%dT%H:%M:%S.%000Z")
|
||||
else
|
||||
valid_from=$(date -u -d "-1 day" +"%Y-%m-%dT%H:%M:%S.%3NZ")
|
||||
valid_until=$(date -u -d "+3 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_KEY_ID=$bpp_subscriber_key_id"
|
||||
"WEBHOOK_URL=$webhook_url"
|
||||
"USE_LAYER_2_CONFIG"=true
|
||||
"MANDATE_LAYER_2_CONFIG"=true
|
||||
|
||||
)
|
||||
|
||||
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_KEY_ID"]=$bpp_subscriber_key_id
|
||||
["WEBHOOK_URL"]=$webhook_url
|
||||
["USE_LAYER_2_CONFIG"]=true
|
||||
["MANDATE_LAYER_2_CONFIG"]=true
|
||||
|
||||
)
|
||||
|
||||
echo "Configuring BPP 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_key_id" "$bpp_subscriber_url" "$public_key" "$public_key" "$valid_from" "$valid_until" "$type"
|
||||
@@ -1,120 +0,0 @@
|
||||
#!/bin/bash
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $SCRIPT_DIR/get_container_details.sh
|
||||
|
||||
gateway_id=gateway
|
||||
gateway_port=4030
|
||||
protocol=http
|
||||
reg_url=http://$1:3030/subscribers/lookup
|
||||
registry_id=registry
|
||||
registry_url=http://registry:3030
|
||||
|
||||
update_network_json(){
|
||||
cp $SCRIPT_DIR/../gateway_data/config/networks/onix.json-sample $SCRIPT_DIR/../gateway_data/config/networks/onix.json
|
||||
networks_config_file="$SCRIPT_DIR/../gateway_data/config/networks/onix.json"
|
||||
tmp_file=$(mktemp "tempfile.XXXXXXXXXX")
|
||||
sed " s|GATEWAY_ID|$gateway_id|g; s|REGISTRY_ID|$registry_id|g; s|REGISTRY_URL|$registry_url|g" "$networks_config_file" > "$tmp_file"
|
||||
mv "$tmp_file" "$networks_config_file"
|
||||
docker run --rm -v $SCRIPT_DIR/../gateway_data/config:/source -v gateway_data_volume:/target busybox cp -r /source/networks /target/
|
||||
}
|
||||
|
||||
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_id|g; s|SIGNING_PUBLIC_KEY|$signing_public_key|g; s|ENCRYPTION_PUBLIC_KEY|$encr_public_key|g; s|GATEWAY_URL|$gateway_id|g; s|GATEWAY_PORT|$gateway_port|g; s|PROTOCOL|$protocol|g; s|REGISTRY_URL|$subscriber_url|g" "$config_file" > "$tmp_file"
|
||||
sed " s|SUBSCRIBER_ID|$gateway_id|g; s|GATEWAY_URL|$gateway_id|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"
|
||||
docker volume create gateway_data_volume
|
||||
docker volume create gateway_database_volume
|
||||
docker run --rm -v $SCRIPT_DIR/../gateway_data/config:/source -v gateway_data_volume:/target busybox cp /source/{envvars,logger.properties,swf.properties} /target/
|
||||
update_network_json
|
||||
|
||||
}
|
||||
|
||||
# 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
|
||||
|
||||
echo "Registry: $1 && Gateway: $2"
|
||||
|
||||
if [[ $1 ]]; then
|
||||
registry_url=$1
|
||||
if [[ $1 == https://* ]]; then
|
||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
||||
registry_id=$(echo "$1" | sed -E 's/https:\/\///')
|
||||
else
|
||||
registry_id=$(echo "$1" | sed 's/https:\/\///')
|
||||
fi
|
||||
elif [[ $1 == http://* ]]; then
|
||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
||||
registry_id=$(echo "$1" | sed -E 's/http:\/\///')
|
||||
else
|
||||
registry_id=$(echo "$1" | sed 's/http:\/\///')
|
||||
fi
|
||||
fi
|
||||
if [[ $registry_id = "registry:3030" ]]; then
|
||||
registry_id="registry"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $2 ]]; then
|
||||
if [[ $2 == https://* ]]; then
|
||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
||||
gateway_id=$(echo "$2" | sed -E 's/https:\/\///')
|
||||
else
|
||||
gateway_id=$(echo "$2" | sed 's/https:\/\///')
|
||||
fi
|
||||
gateway_port=443
|
||||
protocol=https
|
||||
update_gateway_config
|
||||
elif [[ $2 == http://* ]]; then
|
||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
||||
gateway_id=$(echo "$2" | sed -E 's/http:\/\///')
|
||||
else
|
||||
gateway_id=$(echo "$2" | sed 's/http:\/\///')
|
||||
fi
|
||||
gateway_port=80
|
||||
protocol=http
|
||||
update_gateway_config
|
||||
fi
|
||||
else
|
||||
update_gateway_config
|
||||
fi
|
||||
@@ -1,60 +0,0 @@
|
||||
#!/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_key_id="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_key_id="bpp-network-key"
|
||||
bpp_subscriber_url="http://bpp-network:6002"
|
||||
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
|
||||
bap_docker_compose_file=docker-compose-bap.yml
|
||||
registry_docker_compose_file=docker-compose-registry.yml
|
||||
gateway_docker_compose_file=docker-compose-gateway.yml
|
||||
gcl_docker_compose_file=docker-compose-gcl.yml
|
||||
Reference in New Issue
Block a user