Script Examples - UNIX
The following examples show how to create an Agent object (HOST), download and extract an agent and /or TLS Gateway pack, and optionally install and start the ServiceManager for SQL, REST, and UNIX (Linux) Agents, as well as for the TLS Gateway.
Important! The ServiceManager installation is not secured. For more information, see CAPKI - Securing the ServiceManager.
This page includes the following:
REST Agent
The following parameters are used for the REST examples:
REST_ENDPOINT="https://hostname:8088" CLIENT="100" AGENT_NAME="REST13" AE_USER_PW="USER/DEPARTMENT:password" INSTALL_FOLDER="/home/user/testrest"
With ServiceManager
echo "Create Agent $AGENT_NAME" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agents" BODY="{\"name\" : \"$AGENT_NAME\", \"template\" : \"AGENT.WEBSERVICEREST\"}" curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --user "$AE_USER_PW" \ "$URL" echo "Create Agent package" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agentpacks" BODY="{\"name\" : \"$AGENT_NAME\", \"platform\" : \"RA\", \"service_manager\" : { \"operating_system\" : \"Linux\", \"operating_system_architecture\" : \"x64\" } }" LOCATION=$(curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --dump-header - \ --user "$AE_USER_PW" \ "$URL" | grep "Location" | cut -d" " -f2) ZIP_URL="$(sed -e 's/[[:space:]]*$//' <<<${LOCATION})" echo "Download $ZIP_URL" curl --user "$AE_USER_PW" "$ZIP_URL" --output "./tmp.zip" unzip "./tmp.zip" -d "$INSTALL_FOLDER" rm "./tmp.zip" sed -i "s/^name=.*/name=$AGENT_NAME/" "$INSTALL_FOLDER/agent/bin/ucxjcitx.ini" sed -i "s/^port=.*/port=8873/" "$INSTALL_FOLDER/smgr/bin/ucybsmgr.ini" chmod 755 "$INSTALL_FOLDER/smgr/bin"/ucybs* echo "Start ServiceManager" cd "$INSTALL_FOLDER/smgr/bin" nohup ./ucybsmgr AUTOMIC &
Without ServiceManager
echo "Create Agent $AGENT_NAME" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agents" BODY="{\"name\" : \"$AGENT_NAME\", \"template\" : \"AGENT.WEBSERVICEREST\"}" curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --user "$AE_USER_PW" \ "$URL" echo "Create Agent package" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agentpacks" BODY="{\"name\" : \"$AGENT_NAME\", \"platform\" : \"RA\"}" LOCATION=$(curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --dump-header - \ --user "$AE_USER_PW" \ "$URL" | grep "Location" | cut -d" " -f2) ZIP_URL="$(sed -e 's/[[:space:]]*$//' <<<${LOCATION})" echo "Download $ZIP_URL" curl --user "$AE_USER_PW" "$ZIP_URL" --output "./tmp.zip" unzip "./tmp.zip" -d "$INSTALL_FOLDER" rm "./tmp.zip" sed -i "s/^name=.*/name=$AGENT_NAME/" "$INSTALL_FOLDER/agent/bin/ucxjcitx.ini" echo "Start Agent $AGENT_NAME" ( cd "$INSTALL_FOLDER/agent/bin"; java -Xmx1024M -jar ucxjcitx.jar &>/dev/null ) &
SQL Agent
The following parameters are used for the SQL examples:
REST_ENDPOINT="https://hostname:8088" CLIENT="100" AGENT_NAME="SQL13" AE_USER_PW="USER/DEPARTMENT:password" INSTALL_FOLDER="/home/user/testsql" JDBC_DRIVERS="/home/user/jdbc"
With ServiceManager
echo "Create Agent $AGENT_NAME" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agents" BODY="{\"name\" : \"$AGENT_NAME\", \"template\" : \"<SQL>\"}" curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --user "$AE_USER_PW" \ "$URL" echo "Create Agent package" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agentpacks" BODY="{\"name\" : \"$AGENT_NAME\", \"platform\" : \"SQL\", \"service_manager\" : { \"operating_system\" : \"Linux\", \"operating_system_architecture\" : \"x64\" } }" LOCATION=$(curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --dump-header - \ --user "$AE_USER_PW" \ "$URL" | grep "Location" | cut -d" " -f2) ZIP_URL="$(sed -e 's/[[:space:]]*$//' <<<${LOCATION})" echo "Download $ZIP_URL" curl --user "$AE_USER_PW" "$ZIP_URL" --output "./tmp.zip" unzip "./tmp.zip" -d "$INSTALL_FOLDER" rm "./tmp.zip" sed -i "s/^name=.*/name=$AGENT_NAME/" "$INSTALL_FOLDER/agent/bin/ucxjsqlx.ini" cp "$JDBC_DRIVERS/"*.jar "$INSTALL_FOLDER/agent/bin/jdbc" sed -i "s/^port=.*/port=8873/" "$INSTALL_FOLDER/smgr/bin/ucybsmgr.ini" chmod 755 "$INSTALL_FOLDER/smgr/bin"/ucybs* echo "Start ServiceManager" cd "$INSTALL_FOLDER/smgr/bin" nohup ./ucybsmgr AUTOMIC &
Without ServiceManager
echo "Create Agent $AGENT_NAME" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agents" BODY="{\"name\" : \"$AGENT_NAME\", \"template\" : \"<SQL>\"}" curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --user "$AE_USER_PW" \ "$URL" echo "Create Agent package" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agentpacks" BODY="{\"name\" : \"$AGENT_NAME\", \"platform\" : \"SQL\"}" LOCATION=$(curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --dump-header - \ --user "$AE_USER_PW" \ "$URL" | grep "Location" | cut -d" " -f2) ZIP_URL="$(sed -e 's/[[:space:]]*$//' <<<${LOCATION})" echo "Download $ZIP_URL" curl --user "$AE_USER_PW" "$ZIP_URL" --output "./tmp.zip" unzip "./tmp.zip" -d "$INSTALL_FOLDER" rm "./tmp.zip" sed -i "s/^name=.*/name=$AGENT_NAME/" "$INSTALL_FOLDER/agent/bin/ucxjsqlx.ini" cp "$JDBC_DRIVERS/"*.jar "$INSTALL_FOLDER/agent/bin/jdbc" echo "Start Agent $AGENT_NAME" ( cd "$INSTALL_FOLDER/agent/bin"; java -Xmx512M -jar ucxjsqlx.jar &>/dev/null ) &
UNIX (Linux) Agent
The following parameters are used for the UNIX (Linux) examples:
REST_ENDPOINT="https://hostname:8088" CLIENT="100" AGENT_NAME="LINUX13" AE_USER_PW="USER/DEPARTMENT:password" INSTALL_FOLDER="/home/user/testlinux"
With ServiceManager
echo "Create Agent $AGENT_NAME" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agents" BODY="{\"name\" : \"$AGENT_NAME\", \"template\" : \"<UNIX>\"}" curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --user "$AE_USER_PW" \ "$URL" echo "Create Agent package" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agentpacks" BODY="{\"name\" : \"$AGENT_NAME\", \"platform\" : \"UNIX\", \"operating_system\" : \"Linux\", \"operating_system_architecture\" : \"x64\", \"service_manager\" : { \"operating_system\" : \"Linux\", \"operating_system_architecture\" : \"x64\" } }" LOCATION=$(curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --dump-header - \ --user "$AE_USER_PW" \ "$URL" | grep "Location" | cut -d" " -f2) ZIP_URL="$(sed -e 's/[[:space:]]*$//' <<<${LOCATION})" echo "Download $ZIP_URL" curl --user "$AE_USER_PW" "$ZIP_URL" --output "./tmp.zip" unzip "./tmp.zip" -d "$INSTALL_FOLDER" rm "./tmp.zip" sed -i "s/^name=.*/name=$AGENT_NAME/" "$INSTALL_FOLDER/agent/bin/ucxjlx6.ini" chmod 755 "$INSTALL_FOLDER/agent/bin"/ucxj* sed -i "s/^port=.*/port=8873/" "$INSTALL_FOLDER/smgr/bin/ucybsmgr.ini" chmod 755 "$INSTALL_FOLDER/smgr/bin"/ucybs* echo "Start ServiceManager" cd "$INSTALL_FOLDER/smgr/bin" nohup ./ucybsmgr AUTOMIC &
Without ServiceManager
echo "Create Agent $AGENT_NAME" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agents" BODY="{\"name\" : \"$AGENT_NAME\", \"template\" : \"<UNIX>\"}" curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --user "$AE_USER_PW" \ "$URL" echo "Create Agent package" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agentpacks" BODY="{\"name\" : \"$AGENT_NAME\", \"platform\" : \"UNIX\", \"operating_system\" : \"Linux\", \"operating_system_architecture\" : \"x64\" }" LOCATION=$(curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --dump-header - \ --user "$AE_USER_PW" \ "$URL" | grep "Location" | cut -d" " -f2) ZIP_URL="$(sed -e 's/[[:space:]]*$//' <<<${LOCATION})" echo "Download $ZIP_URL" curl --user "$AE_USER_PW" "$ZIP_URL" --output "./tmp.zip" unzip "./tmp.zip" -d "$INSTALL_FOLDER" rm "./tmp.zip" sed -i "s/^name=.*/name=$AGENT_NAME/" "$INSTALL_FOLDER/agent/bin/ucxjlx6.ini" chmod 755 "$INSTALL_FOLDER/agent/bin"/ucxj* echo "Start Agent $AGENT_NAME" ( cd "$INSTALL_FOLDER/agent/bin"; ./ucxjlx6 &>/dev/null ) &
TLS Gateway
The following parameters are used for the TLS Gateway examples:
REST_ENDPOINT="https://hostname:8088" CLIENT="100" AGENT_NAME="TLS_GATEWAY1" AE_USER_PW="USER/DEPARTMENT:password" INSTALL_FOLDER="/home/user/testtlsgtw"
With ServiceManager
echo "Create Agent $AGENT_NAME" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agents" BODY="{\"name\" : \"$AGENT_NAME\", \"template\" : \"AGENT.TLS-GATEWAY\"}" curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --user "$AE_USER_PW" \ "$URL" echo "Create Agent package" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agentpacks" BODY="{\"name\" : \"$AGENT_NAME\", \"platform\" : \"TLS_GTW\", \"service_manager\" : { \"operating_system\" : \"Linux\", \"operating_system_architecture\" : \"x64\" } }" LOCATION=$(curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --dump-header - \ --user "$AE_USER_PW" \ "$URL" | grep "Location" | cut -d" " -f2) ZIP_URL="$(sed -e 's/[[:space:]]*$//' <<<${LOCATION})" echo "Download $ZIP_URL" curl --user "$AE_USER_PW" "$ZIP_URL" --output "./tmp.zip" unzip "./tmp.zip" -d "$INSTALL_FOLDER" rm "./tmp.zip" sed -i "s/^name=.*/name=$AGENT_NAME/" "$INSTALL_FOLDER/agent/bin/uctlsgtw.ini" sed -i "s/^port=.*/port=8873/" "$INSTALL_FOLDER/smgr/bin/ucybsmgr.ini" chmod 755 "$INSTALL_FOLDER/smgr/bin"/ucybs* echo "Start ServiceManager" cd "$INSTALL_FOLDER/smgr/bin" nohup ./ucybsmgr AUTOMIC &
Without ServiceManager
echo "Create Agent $AGENT_NAME" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agents" BODY="{\"name\" : \"$AGENT_NAME\", \"template\" : \"AGENT.TLS-GATEWAY\"}" curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --user "$AE_USER_PW" \ "$URL" echo "Create Agent package" URL="$REST_ENDPOINT/ae/api/v1/$CLIENT/system/agentpacks" BODY="{\"name\" : \"$AGENT_NAME\", \"platform\" : \"TLS_GTW\"}" LOCATION=$(curl --header "Content-Type: application/json" \ --request POST \ --data "$BODY" \ --dump-header - \ --user "$AE_USER_PW" \ "$URL" | grep "Location" | cut -d" " -f2) ZIP_URL="$(sed -e 's/[[:space:]]*$//' <<<${LOCATION})" echo "Download $ZIP_URL" curl --user "$AE_USER_PW" "$ZIP_URL" --output "./tmp.zip" unzip "./tmp.zip" -d "$INSTALL_FOLDER" rm "./tmp.zip" sed -i "s/^name=.*/name=$AGENT_NAME/" "$INSTALL_FOLDER/agent/bin/uctlsgtw.ini" echo "Start Agent $AGENT_NAME" ( cd "$INSTALL_FOLDER/agent/bin"; java -Xmx1024M -jar uctlsgtw.jar &>/dev/null ) &
See also: