Script-Beispiele – UNIX

Die folgenden Beispiele zeigen, wie man ein Agentenobjekt (HOST) erstellt, einen Agenten und/oder ein TLS Gateway-Pack herunterlädt und extrahiert und optional den ServiceManager für SQL-, REST- und UNIX (Linux)-Agenten installiert und startet, ebenso wie für das TLS Gateway.

Wichtig! Die ServiceManager-Installation ist nicht gesichert. Weitere Informationen finden Sie unter CAPKI - Sicherung des ServiceManagers.

Diese Seite beinhaltet Folgendes:

 REST-Agent

Die folgenden Parameter werden für die REST-Beispiele verwendet:

REST_ENDPOINT="https://hostname:8088"
CLIENT="100"
AGENT_NAME="REST13"
AE_USER_PW="USER/DEPARTMENT:password"
INSTALL_FOLDER="/home/user/testrest"

Mit 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 &

Ohne 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

Die folgenden Parameter werden für die SQL-Beispiele verwendet:

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"

Mit 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 &

Ohne 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)-Agenten

Die folgenden Parameter werden für UNIX (Linux)-Beispiele verwendet:

REST_ENDPOINT="https://hostname:8088"
CLIENT="100"
AGENT_NAME="LINUX13"
AE_USER_PW="USER/DEPARTMENT:password"
INSTALL_FOLDER="/home/user/testlinux"

Mit 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 &

Ohne 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

Die folgenden Parameter werden für TLS Gateway-Beispiele verwendet:

REST_ENDPOINT="https://hostname:8088"
CLIENT="100"
AGENT_NAME="TLS_GATEWAY1"
AE_USER_PW="USER/DEPARTMENT:password"
INSTALL_FOLDER="/home/user/testtlsgtw"

Mit 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 &

Ohne 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 ) &

Siehe auch: