Fixed code to update networks onix.json file
This commit is contained in:
11
install/gateway_data/config/networks/onix.json-sample
Normal file
11
install/gateway_data/config/networks/onix.json-sample
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"core_version" : "1.1.0",
|
||||||
|
"registry_id": "REGISTRY_ID..LREG",
|
||||||
|
"search_provider_id" : "GATEWAY_ID",
|
||||||
|
"self_registration_supported": true,
|
||||||
|
"subscription_needed_post_registration" : true,
|
||||||
|
"base_url": "REGISTRY_URL",
|
||||||
|
"registry_url" : "REGISTRY_URL/subscribers",
|
||||||
|
"extension_package": "in.succinct.beckn.boc",
|
||||||
|
"wild_card" : ""
|
||||||
|
}
|
||||||
@@ -2,10 +2,20 @@
|
|||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
source $SCRIPT_DIR/get_container_details.sh
|
source $SCRIPT_DIR/get_container_details.sh
|
||||||
|
|
||||||
gateway_url=gateway
|
gateway_id=gateway
|
||||||
gateway_port=4030
|
gateway_port=4030
|
||||||
protocol=http
|
protocol=http
|
||||||
reg_url=http://$1:3030/subscribers/lookup
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
get_details_registry() {
|
get_details_registry() {
|
||||||
# Make the curl request and store the output in a variable
|
# Make the curl request and store the output in a variable
|
||||||
@@ -36,42 +46,62 @@ update_gateway_config() {
|
|||||||
config_file="$SCRIPT_DIR/../gateway_data/config/swf.properties"
|
config_file="$SCRIPT_DIR/../gateway_data/config/swf.properties"
|
||||||
|
|
||||||
tmp_file=$(mktemp "tempfile.XXXXXXXXXX")
|
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"
|
#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"
|
mv "$tmp_file" "$config_file"
|
||||||
|
update_network_json
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $1 == https://* ]]; then
|
# if [[ $1 == https://* ]]; then
|
||||||
reg_url=$1/subscribers/lookup
|
# reg_url=$1/subscribers/lookup
|
||||||
get_details_registry $reg_url
|
# get_details_registry $reg_url
|
||||||
else
|
# else
|
||||||
service_name=$1
|
# service_name=$1
|
||||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
# if [[ $(uname -s) == 'Darwin' ]]; then
|
||||||
ip=localhost
|
# ip=localhost
|
||||||
elif [[ $(systemd-detect-virt) == 'wsl' ]]; then
|
# elif [[ $(systemd-detect-virt) == 'wsl' ]]; then
|
||||||
ip=$(hostname -I | awk '{print $1}')
|
# ip=$(hostname -I | awk '{print $1}')
|
||||||
else
|
# else
|
||||||
ip=$(get_container_ip $service_name)
|
# ip=$(get_container_ip $service_name)
|
||||||
fi
|
# fi
|
||||||
reg_url=http://$ip:3030/subscribers/lookup
|
# reg_url=http://$ip:3030/subscribers/lookup
|
||||||
get_details_registry $reg_url
|
# get_details_registry $reg_url
|
||||||
fi
|
# 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
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $2 ]]; then
|
if [[ $2 ]]; then
|
||||||
if [[ $2 == https://* ]]; then
|
if [[ $2 == https://* ]]; then
|
||||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
if [[ $(uname -s) == 'Darwin' ]]; then
|
||||||
gateway_url=$(echo "$2" | sed -E 's/https:\/\///')
|
gateway_id=$(echo "$2" | sed -E 's/https:\/\///')
|
||||||
else
|
else
|
||||||
gateway_url=$(echo "$2" | sed 's/https:\/\///')
|
gateway_id=$(echo "$2" | sed 's/https:\/\///')
|
||||||
fi
|
fi
|
||||||
gateway_port=443
|
gateway_port=443
|
||||||
protocol=https
|
protocol=https
|
||||||
update_gateway_config
|
update_gateway_config
|
||||||
elif [[ $2 == http://* ]]; then
|
elif [[ $2 == http://* ]]; then
|
||||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
if [[ $(uname -s) == 'Darwin' ]]; then
|
||||||
gateway_url=$(echo "$2" | sed -E 's/http:\/\///')
|
gateway_id=$(echo "$2" | sed -E 's/http:\/\///')
|
||||||
else
|
else
|
||||||
gateway_url=$(echo "$2" | sed 's/http:\/\///')
|
gateway_id=$(echo "$2" | sed 's/http:\/\///')
|
||||||
fi
|
fi
|
||||||
gateway_port=80
|
gateway_port=80
|
||||||
protocol=http
|
protocol=http
|
||||||
|
|||||||
Reference in New Issue
Block a user