Nudge still popping up during aggressive mode after user clicks to Upgrade

Antbanks51
New Contributor III

Sorry for the long title.

We were doing some testing with Nudge and found out that once you hit the deadline and Nudge enters aggressive mode that it still pops up even after you click to update the device.  My manager said when he waited and got to that date he was unable to use his device while it updated since Nudge kept popping back up. 

Is there a way around this?  I just added a long refresh cycle in the user experience tab to test but wanted to check here in case that is wrong.

1 ACCEPTED SOLUTION

sdagley
Esteemed Contributor II

@Antbanks51 That's the expected behavior. Nudge does its thing until the Mac is updated because you can't really trust that a user who clicks Update will actually do the same when they reach the Software Update screen.

View solution in original post

2 REPLIES 2

sdagley
Esteemed Contributor II

@Antbanks51 That's the expected behavior. Nudge does its thing until the Mac is updated because you can't really trust that a user who clicks Update will actually do the same when they reach the Software Update screen.

mickgrant
Contributor III

I used Nudge to run a self-service Erase-Install script instead of the built-in MacOS update menu, and I had the same issue: people would click update, and while the update was downloading, they would be nudged again. It was annoying.

So what I did was unload the nudge launch agent within the script and then have the launch agent be restarted at the end of the script

#!/bin/sh
# Unload Nudge Launch Agent and Begin MacOS upgrade script
# Written by Mick Grant - mgrant1@arm.catholic.edu.au

# find active user code supplied by Armin Briegel - Scripting OS X
# sample code for this blog post
# https://scriptingosx.com/2020/08/running-a-command-as-another-user/

# variable and function declarations

export PATH=/usr/bin:/bin:/usr/sbin:/sbin

# get the currently logged in user
currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )

# global check if there is a user logged in
if [ -z "$currentUser" -o "$currentUser" = "loginwindow" ]; then
  echo "no user logged in, cannot proceed"
  exit 1
fi
# now we know a user is logged in

# get the current user's UID
uid=$(id -u "$currentUser")

# convenience function to run a command as the current user
# usage:
#   runAsUser command arguments...
runAsUser() {  
  if [ "$currentUser" != "loginwindow" ]; then
    launchctl asuser "$uid" sudo -u "$currentUser" "$@"
  else
    echo "no user logged in"
    # uncomment the exit command
    # to make the function exit with an error when no user is logged in
    # exit 1
  fi
}

# main code starts here

#kill the running nudge process
killall Nudge
echo "killing the running nudge window"

# unload the com.github.macadmins.nudge launch agent
runAsUser launchctl unload /Library/LaunchAgents/com.github.macadmins.Nudge.plist
echo "Nudge launch agent has been unloaded"

#launch erase-install 
echo "Erase-install script active, installing macOS - "$4"."
/Library/Management/erase-install/erase-install.sh --reinstall --current-user --check-power --version=$4 --cleanup-after-use --rebootdelay 300 --no-timeout --overwrite

# reload the com.github.macadmins.nudge launch agent if Erase-install script fails, so that nudge will keep activating
runAsUser launchctl load /Library/LaunchAgents/com.github.macadmins.Nudge.plist
echo "Nudge launch agent has been loaded. Your not getting away from me that easily"