Skip to content
Snippets Groups Projects
Commit f9d7bb44 authored by Eric Schoville's avatar Eric Schoville
Browse files

Update run_agent.sh

parent 32e6ce60
No related branches found
No related tags found
No related merge requests found
...@@ -102,8 +102,6 @@ ic_session_id=${result[1]} ...@@ -102,8 +102,6 @@ ic_session_id=${result[1]}
if [ -z ${server_url+x} ]; then if [ -z ${server_url+x} ]; then
echo "No Server URL set" echo "No Server URL set"
exit 1 exit 1
else
echo "Server URL: ${server_url}"
fi fi
if [ -z ${ic_session_id+x} ]; then if [ -z ${ic_session_id+x} ]; then
...@@ -111,47 +109,39 @@ if [ -z ${ic_session_id+x} ]; then ...@@ -111,47 +109,39 @@ if [ -z ${ic_session_id+x} ]; then
exit 1 exit 1
fi fi
# Check for the existance of infaagent.ini and see if it has been registered. # Check for the existance of infaagent.ini and see if it has been registered.
register=true register=true
config_file="conf/infaagent.ini" agent_id=$(grep -oPs '^InfaAgent.Id=\K.+' conf/infaagent.ini)
if [ -e "$config_file" ]; then
echo "Found infaagent.ini"
agent_id=$(grep -oP '^InfaAgent.Id=\K.+' $config_file)
# Use expansion to check for null
if [ -n "${agent_id+x}" ]; then
# Check the registered agent ID to see if it is running or not. if [ -z "${agent_id}" ]; then
# active seems to be set to true if it has been running recently echo "No agent id found, registering new agent"
# readyToRun means it is up and running else
result=($(curl -sS -H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "icSessionId: ${ic_session_id}" \
"${server_url}/api/v2/agent/${agent_id}" | jq -r '.active, .readyToRun, .name'))
if [ -z "${result[0]}" ]; then
echo "Unable to find agent_id, registering a new agent" # If we find an agent_id, then query the Informatica API and
# check the registered agent ID to see if it is running or not.
# active seems to be set to true if it has been running recently
# readyToRun means it is up and running
elif [[ "${result[0]}" = "true" && "${result[1]}" = "true" ]]; then echo "Checking the status of ${agent_id} using the agent API"
echo "Already exists a running agent with the id of ${agent_id}: ${result[1]}, registering a new agent" result=($(curl -sS -H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "icSessionId: ${ic_session_id}" \
"${server_url}/api/v2/agent/${agent_id}" | jq -r '.active, .readyToRun, .name'))
else if [ -z "${result[0]}" ]; then
#Not running, but exists. This should be the default condition, in which case we would just run the agent echo "Unable to find agent_id, registering a new agent"
register=false
fi elif [[ "${result[0]}" = "true" && "${result[1]}" = "true" ]]; then
echo "Already exists a running agent with the id of ${agent_id}, registering a new agent"
else else
echo "This looks to be a new agent, registering new agent" #Not running, but exists. This should be the default condition, in which case we would just run the agent
register=false
fi fi
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment