diff --git a/install/gateway_data/config/networks/onix.json-sample b/install/gateway_data/config/networks/onix.json-sample new file mode 100644 index 0000000..f89e7f9 --- /dev/null +++ b/install/gateway_data/config/networks/onix.json-sample @@ -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" : "" +} \ No newline at end of file diff --git a/install/scripts/update_gateway_details.sh b/install/scripts/update_gateway_details.sh index 49ba577..f6436e3 100755 --- a/install/scripts/update_gateway_details.sh +++ b/install/scripts/update_gateway_details.sh @@ -2,10 +2,20 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/get_container_details.sh -gateway_url=gateway +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" +} get_details_registry() { # 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" 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" + 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 +# 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 +fi if [[ $2 ]]; then if [[ $2 == https://* ]]; then if [[ $(uname -s) == 'Darwin' ]]; then - gateway_url=$(echo "$2" | sed -E 's/https:\/\///') + gateway_id=$(echo "$2" | sed -E 's/https:\/\///') else - gateway_url=$(echo "$2" | sed 's/https:\/\///') + 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_url=$(echo "$2" | sed -E 's/http:\/\///') + gateway_id=$(echo "$2" | sed -E 's/http:\/\///') else - gateway_url=$(echo "$2" | sed 's/http:\/\///') + gateway_id=$(echo "$2" | sed 's/http:\/\///') fi gateway_port=80 protocol=http