Skip to main content
Question

Self Service - App updates - Script that warns user that app needs to be closed.

  • September 14, 2022
  • 3 replies
  • 0 views

Forum|alt.badge.img+2

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"

 

3 replies

mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • September 14, 2022

Are you seeing an issue with it when using the script parameters? If so, you didn't describe the problem.


I would consider putting double quotes around the parameters when assigning to the variable names, like this:

processName="$4" appName="$5"

I can't be sure if any issue you're seeing with it is related to that, but always a good idea to double quote items like that since 'appName' in particular could easily have spaces in the string.


Forum|alt.badge.img+2
  • Author
  • New Contributor
  • 1 reply
  • September 15, 2022

The close application function works as it should, but even with the quotes there is a loop, the application is closed and a popup is saying that app is open and needs to be closed.

Without parameters it is closing application and going with application install.


Forum|alt.badge.img+10
  • Contributor
  • 88 replies
  • September 19, 2022

Installomator has this function built in, you can take a look at their script to pull what you need. 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings