Reboot after script runs but before package installs

AlistairCarr
New Contributor II

Hi, Wondering if this is possible

I have a policy which needs to uninstall a piece of software via a script, then restart and install a PKG

In the policy I have the script set to run before, but I cannot see how to specify the reboot prior to the package install.

Is it possible?

2 REPLIES 2

thoule
Valued Contributor II

First, are you sure you need to reboot? No way to kill the processes which are interfering? Remove the launchD items?

If you really need to reboot, there's two ways to go about it. If you can create a smart group of these machines somehow, then target them with the installer. Perhaps you can create a touchfile in /Users/Shared/installOnThisMac, then have an EA that looks for that file, adds to smart group, then installs? Kinda messy, but it would work. Don't forget to remove that file after installing!

An alternate route is before you uninstall that software, copy the installer to /Users/Shared and copy a LaunchD to run the installer on reboot. That's how I'd do it. Don't forget to add a PostInstallscript to remove that installer and LaunchD. Let me know if you need help building a LaunchD.

Chris_Hafner
Valued Contributor II

There are a number of ways you could handle this. In general, I'd probably use two policies depending on your specific needs and other such esoterica. That means the first policy would uninstall the software via your script, run a recon and then restart the unit. Then another policy, based off some sort of scope that makes sense in this situation (generally a SMART group looking for the missing piece of software or you could always leave a blank receipt as part of your first policies script) can install the new .pkg Does that make sense?