@@ -421,7 +421,6 @@ status(){
421421 echo " Agent is not installed."
422422 exit 1
423423 fi
424- agentVersion=$( grep agentVersion " $CONFDIR " /config.json | awk ' { print $2 }' | sed ' s/,//g' )
425424 info
426425 if [ " $containerRuntime " = " docker" ]
427426 then
@@ -691,13 +690,34 @@ start()
691690 fi
692691 runAgent
693692 echo " "
694- agentVersion=$( grep agentVersion " $CONFDIR " /config.json | awk ' { print $2 }' | sed ' s/,//g' )
695693 info
696694 echo " "
697695 echo " INFO: Logs directory: ${PV} /data/logs"
698696 echo " INFO: You can monitor the agent ${AI} from the Access Governance Console."
699697}
700698
699+ forceStopPodman ()
700+ {
701+ # Get the main process for the container.
702+ CONTAINER_ID=$( podman ps | grep " $AI " | awk ' {print $1}' )
703+ if [ -n " ${CONTAINER_ID} " ]; then
704+ echo Container ID : " $CONTAINER_ID "
705+ CONTAINER_PROCESS_ID=$( ps -ef | grep -v grep | grep " $CONTAINER_ID " | awk ' {print $2}' )
706+ echo Container Process ID: ${CONTAINER_PROCESS_ID}
707+
708+ # Kill any processes containing the process ID.
709+ # This kills the child processes too.
710+ # shellcheck disable=SC2046
711+ kill -9 ` ps -ef | grep -v grep | grep ${CONTAINER_PROCESS_ID} | awk ' {print $2}' `
712+
713+ # Stop the container, as Podman doesn't notice the processes are dead until you interact with the container.
714+ echo " Stop container. Ignore errors."
715+ podman stop " $AI "
716+ else
717+ echo " Container Already Stopped"
718+ fi
719+ }
720+
701721# shellcheck source=/dev/null
702722stop ()
703723{
@@ -723,6 +743,7 @@ stop()
723743 echo " INFO: Waiting for running operations to complete. It may take some time"
724744 podman exec " $AI " /bin/bash -c ' agent --config /app/data/conf/config.json ido lcm -i status_check; while [[ "$?" != "2" && "$?" != "255" ]]; do sleep 5s;agent --config /app/data/conf/config.json ido lcm -i status_check; done' > /dev/null
725745 podman stop " $AI "
746+ forceStopPodman
726747 fi
727748 echo " INFO: Agent Stopped"
728749}
@@ -1104,4 +1125,4 @@ while [ $# -gt 0 ]; do
11041125 * ) echo " ERROR: agentManagement: Invalid option: \" $opt \" " >&2
11051126 exit 1;;
11061127 esac
1107- done
1128+ done
0 commit comments