Skip to content

Commit 748f128

Browse files
Added config to provide network config (#2803)
* removed -a flag to get container in running state * handled removing of the older image in post upgrade operation * added ServiceNow sample integration scripts * removed Service Now samples * removed Service Now samples * added config to provide network mode while starting an agent --------- Co-authored-by: Rishi Agarwal <[email protected]>
1 parent 0155e43 commit 748f128

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

OracleIdentityGovernance/samples/scripts/agentManagement.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,11 @@ runAgent(){
264264
then
265265
if [ ! "$(docker ps -a -f "name=$AI" --format '{{.Names}}')" ]
266266
then
267-
echo "INFO: Starting new container"
267+
echo "INFO: Starting new container using network mode $NETWORK"
268268
if [ -f "$CONFDIR"/config.properties ]; then
269-
docker run -d --env-file "$CONFDIR"/config.properties -v "$PV":/app --group-add "$groupId" --name "$AI" "$imageName"
269+
docker run -d --network "$NETWORK" --env-file "$CONFDIR"/config.properties -v "$PV":/app --group-add "$groupId" --name "$AI" "$imageName"
270270
else
271-
docker run -d -v "$PV":/app --group-add "$groupId" --name "$AI" "$imageName"
271+
docker run -d --network "$NETWORK" -v "$PV":/app --group-add "$groupId" --name "$AI" "$imageName"
272272
fi
273273
docker exec "$AI" /bin/bash -c 'agent ido validate --config /app/data/conf/config.json; if [[ "$?" != "0" ]] ; then echo VALIDATE_FAILED > /app/data/conf/status.txt; else echo VALIDATE_SUCCESS > /app/data/conf/status.txt; fi ;'
274274
validateStatus=$(cat "$CONFDIR"/status.txt)
@@ -312,11 +312,11 @@ runAgent(){
312312
then
313313
if [ ! "$(podman ps -a -f "name=$AI" --format '{{.Names}}')" ]
314314
then
315-
echo "INFO: Starting new container"
315+
echo "INFO: Starting new container using network mode $NETWORK"
316316
if [ -f "$CONFDIR"/config.properties ]; then
317-
podman run -d --env-file "$CONFDIR"/config.properties -v "$PV":/app --group-add "$groupId" --name "$AI" "$imageName"
317+
podman run -d --network "$NETWORK" --env-file "$CONFDIR"/config.properties -v "$PV":/app --group-add "$groupId" --name "$AI" "$imageName"
318318
else
319-
podman run -d -v "$PV":/app --group-add "$groupId" --name "$AI" "$imageName"
319+
podman run -d --network "$NETWORK" -v "$PV":/app --group-add "$groupId" --name "$AI" "$imageName"
320320
fi
321321

322322
podman exec "$AI" /bin/bash -c 'agent ido validate --config /app/data/conf/config.json; if [[ "$?" != "0" ]] ; then echo VALIDATE_FAILED > /app/data/conf/status.txt; else echo VALIDATE_SUCCESS > /app/data/conf/status.txt; fi ;'
@@ -692,6 +692,10 @@ start()
692692
if [ -f "$configOverride" ]; then
693693
kill
694694
fi
695+
if [ "$NETWORK" = "" ];
696+
then
697+
NETWORK="host"
698+
fi
695699
runAgent
696700
echo ""
697701
agentVersion=$(grep agentVersion "$CONFDIR"/config.json | awk '{ print $2 }' | sed 's/,//g')
@@ -1030,6 +1034,8 @@ Help()
10301034
echo "-ap|--agentpackage No(Required in validate,install
10311035
and upgrade) \"\" Agent Package Path"
10321036
echo "-c|--config No - Path of the custom config property file"
1037+
echo "-n|--network No host Configuration to change the network type
1038+
of the container runtime."
10331039
echo "-pv|--volume Yes - Directory to persist agent data such as
10341040
configuration, wallet, logs, etc."
10351041

@@ -1095,6 +1101,7 @@ while [ $# -gt 0 ]; do
10951101
"-pv"|"--volume" ) createDir "$1"; echo PV="$(cd "$(dirname "$1")" || exit 1; pwd -P)"/"$(basename "$1")" >> "$ENV_FILE_TEMP"; shift;;
10961102
"-h"|"--help" ) Help; exit 1;;
10971103
"-ai"|"--agentid" ) echo AI="$1" >> "$ENV_FILE_TEMP"; shift;;
1104+
"-n"|"--network" ) echo NETWORK="$1" >> "$ENV_FILE_TEMP"; shift;;
10981105
"-au"|"--autoupgrade" ) echo AU="$1" >> "$ENV_FILE_TEMP"; shift;;
10991106
"-ap"|"--agentpackage" ) echo AP="$(cd "$(dirname "$1")" || exit 1; pwd -P)"/"$(basename "$1")" >> "$ENV_FILE_TEMP"; shift;;
11001107
"-c"|"--config" ) configOverride=$(cd "$(dirname "$1")" || exit 1; pwd -P)/$(basename "$1"); shift;;

0 commit comments

Comments
 (0)