#!/bin/bash 

Config_Agent() {
    agent_root=$1
    agent_hub_uri=$2

    agent_hub_placeholder="###AGENTHUBURL###"
    igw_placeholder="###INTGWURL###"
    config_path="$agent_root/service/appsettings.json"
    igw_url="${agent_hub_uri//https/http}:5001/service_repo/xray/"

    if [ -s "$config_path" ]
    then
        sed -E -i "s!$agent_hub_placeholder!$agent_hub_uri!g" "$config_path"
        sed -E -i "s!$igw_placeholder!$igw_url!g" "$config_path"
    else
        Write_Log "Agent config file not found. Check Agent installation" "ERROR"
        return 1
    fi
}
