How do you stop OSX going to sleep during your larger package installs?

nigelg
Contributor

My institution is trying to reduce energy costs and environmental impact etc so I have a 10 minute display sleep/30 minute sleep configuration profile installed on all machines. This is installed manually using the "profiles" command - I package mobileconfigs and deploy them in scripted packages.

During large installs the machines tend to sleep. For example I have a DMG for Logic Pro X including all the samples which is around 33GB in size. When I look at the Casper logs, i can see the policy start to verify the package (it starts to download) then it starts to install and the logs stop for a long time. At this point the machine has gone to sleep and if I wake it up, the policy that triggered the package install shows that it has completed but the directories are not complete on the machine - in this particular case the Logic samples folder was around 11GB instead of 20+.

I would like to incorporate the caffeinate command into my scripts/packages/installs to guarantee that the machines stay awake and I wanted to know if anyone is using this method or has any idea how best to keep it running while the packages are installed. I could place packages within packages and use a post install script to start the installation of the contained package using "caffeinate installer etc etc" but that doesn't help with DMGs. DMGs have the obvious benefit of spraying user files into the template directory and /Users and I don't want to lose this functionality. I could split the user files off into separate DMGs that would be faster to install but I would prefer to keep program files and user settings in the same place if possible.

7 REPLIES 7

Not applicable

Coffee?

calumhunter
Valued Contributor

Hmm have you tried to run caffeinate as a command in the policy as a "before" action and then run another command "after" to kill caffeinate?

nigelg
Contributor

Ok I will create a script that runs before that does "caffeinate &" to fire caffeinate in a background process and another script to "killall caffeinate" after everything else is done. That should do it, don't know why I didn't think of that myself. Need 2 heads sometimes.

I did the same thing to trigger jamf policy remotely - just doing a script of "jamf policy" and using casper remote doesn't get policies but using "jamf policy &" in a script does trigger policy checking remotely. Same works with "jamf recon &" to get inventory checking going using casper remote.

I will give it a test.

nigelg
Contributor

This works really well.

coachdnadel
Release Candidate Programs Tester

Can you share the scripts you used?

Look
Valued Contributor III

I am using during my first boot script...
-t 18000 is an eventual timeout in case the kill somehow fails. You can probably skip the -d as this is the display, I just have it as I like to be able to see what is happening during the script.

caffeinate -i -s -d -t 18000 &

and

killall caffeinate

reidg
New Contributor III

Thanks for posting these caffeinate scripts and variables.They work great.

I was having some problems with Adobe's Creative Cloud which is about 15 GB compressed. Caffeinating before the package made the deployments much more reliable.