Alternative method is to make an API call towards HQ in order to create new environment. Read more about HQ's API references here.
create_new_env.sh
#!/bin/bash# Variables for URLs and endpointsURL_LOGIN="http://hq:9991/api/v1/login"URL_DATA="http://hq:9991/api/v1/environments"# Check if the file exists and is not emptyifgrep-q'^agent'"$FILE"; thenecho"[INFO] Environment has already been created -> Proceeding with the Agent creation"exit0else# Step 1: Perform the first request to get the session cookie# Replace the login payload and headers as per your requirements response=$(curl-s-D- \-XPOST \-H'Accept: application/json' \-H"Content-Type: application/json" \-d'{"username":"admin", "password":"admin"}' \ $URL_LOGIN)# Step 2: Extract the session cookie from the response headers# Assuming the session cookie is called "session_id" in the response cookie=$(echo"$response"|grep-i'Set-Cookie'|grep-o'session_id=[^;]*')if [ -z"$cookie" ]; thenecho"[ERROR] Failed to retrieve session cookie"exit1fiecho"[INFO] Session Cookie: $cookie"# Step 3: Use the session cookie to make another request response_body=$(curl-s \-XPOST \-H"Cookie: $cookie" \-H"Content-Type: application/json" \-d'{ "name": "demo-environment", "tier": "development" }' \ $URL_DATA)