Posted on 04-28-2020 07:48 AM
I have a policy that runs at check-in (or from Self Service) that installs a few packages and then runs a script. I need to have a "completed" message come up for the end user. (and stay open)
I'm currently using JamfHelper to do this and that works great. But what I'd like to do is have that message stay open and finish the script and then finish the policy. **and leave that pop up message open
I added the & after the JamfHelper command, which lets everything else finish in the script and then the policy itself finishes. But I found that after the policy is done, that it kills the jamfHelper process and the pop up message goes away.
I think i need to find a way for the jamfHelper to be launched in a separate "process", so when jamf closes the policy, that it will leave that running. But I'm not sure how to do that.
Posted on 04-28-2020 08:32 AM
Update on this. I found that running the policy from Self Service will let the script and policy finish and leave the message open. But when the same policy runs as "At Check-in" than, once the policy is done, the message goes away.
Posted on 04-28-2020 09:17 AM
Hi @jleomcdo ,
Maybe you could try adding a If Statement to the end of your command.
#!/bin/bash
#Example Jamf Helper script with if statement
answer=$("/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper" -windowType hud -button1 Okay -defaultButton 0)
if [[ $answer -eq 0 ]];
then
echo "The user clicked Okay"
else
echo "Something went wrong"
fi
Posted on 04-28-2020 10:50 AM
I did think of that the other day, so I added some code at the end of the script to detect if the "OK" button was clicked or not. This works if you run the script manually (not with jamf policy). But once again, if the policy that runs the script is running "at check in" then, once the policy is finished, it will close out the message.
Posted on 04-30-2020 10:35 AM
An update on this, in case others are looking to do the same thing. I ended up using Pashua (like cocaDialog) to create my pop up message. Then added "count loop" to wait 10 minutes before the policy / scripts is done. No perfect, but is better than the message going away in less than a minute.
Here is part of the script that displays the message, then waits 10 minutes. (unless user presses OK)
#!/bin/bash
... more code ....
source "/opt/Pashua/pashua.sh"
customLocation='/opt/Pashua'
conf="
*.title = Finished
*.floating = 1
img.type = image
img.path = /Library/Application Support/JAMF/PerrigoLogo.png
img.label = All updates have been installed. Thank you!
img.width = 120
img.height = 80
db.type = defaultbutton
"
# Reboot, if needed
echo "#########################"
if [ "$RebootNeeded" = "1" ]; then
echo "Reboot needed"
jamf reboot -minutes 5 -message "Updates are finished. Your computer will reboot in 5 minutes." -background -startTimerImmediately
exit
else
echo "No reboot needed."
fi
pashua_run "$conf" "$customLocation" &
msgID=$(ps -A | grep Pashua.app | grep -v grep | awk '{print $1}')
# wait up to 10 minutes, unless OK is pressed.
counter=0
while [ $counter -le 600 ];
do
((counter++))
jamfID=$(ps -A | grep Pashua.app | grep -v grep | awk '{print $1}')
sleep 1
if [ -z "$msgID" ]; then
echo "Button Pushed"
exit
fi
done
echo "All Done, timer expired."
Posted on 05-04-2020 05:34 PM
Glad you found a bandaid for it!
Hindsight, but maybe you could have used an Applescript prompt.
I use this method for a reoccurring script in my environment,
# AppleScript to alert the user that the app needs to close
#Will Autoclose after 10 Minutes (600)
function show_update_alert()
{
/usr/bin/osascript <<-EOD
tell application "Finder"
activate
set DialogTitle to "$APPNAME"
set DialogText to "Teams needs to close to repair your $disabledMessgae permission. Please select ***Allow*** when prompted to grant Teams Access to your $disabledMessgae"
set DialogButton to "Fix Now"
set DialogIcon to "Applications:Microsoft Teams.app:Contents:Resources:icon.icns"
display dialog DialogText buttons {DialogButton} with title DialogTitle with icon file DialogIcon giving up after 600
end tell
EOD
echo "Prompt has completed"
}
show_update_alert