This is my script to notify user that app will be closed.
It is working without trying to use parameters while configuring script.
With coded data to processName and appName notification is working flawlessly.
But I don't want to create script for each app that needs this functionality, that's why I'm asking for help with this script.
#!/bin/bash
#set -x
processName=$4
appName=$5
message="$appName app is currently open.
By pressing <Proceed>
app will be closed and process will continue."
echo "$(date) | Waiting for other [$processName] processes to end"
while ps aux | grep "$processName" | grep -v grep &>/dev/null; do
HELPER=`/Library/Application\\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -defaultButton 1 -lockHUD -description "$message" -windowPosition c -title "$5 Update/Installation" -windowType hud -button1 "Proceed" -alignDescription center -alignHeading center`
if [ "$HELPER" == "0" ]; then
echo "$(date) | User clicked UPGRADE button"
terminate="true"
fi
if [[ $terminate == "true" ]]; then
echo "$(date) | + [$appName] running, terminating [$processName]..."
pkill -f "$processName"
fi
delay=7
echo "$(date) | + Another instance of $processName is running, waiting [$delay] seconds"
sleep $delay
done
echo "$(date) | No instances of [$processName] found, safe to proceed"