Disable Energy Saver options while running Casper policies?

cpdecker
Contributor III

Hello all,

I am having a problem with my remote installs where a computer will be online at the beginning of a policy deployment, but will go into power save mode (hibernate? apologies if my terminology is off) in the middle of the deployment and cause it to fail. The package I'm having the most trouble with is Microsoft Office 2011 since it is so huge.

I found where I can set Energy Saver settings under Configuration Profiles, but I'd really like to have a way to just disable Energy Saver options WHILE a policy is being pushed, so users can retain some control over their Energy Saver preferences. This is happening whether I run sudo jamf policy or schedule the install for the check-in.

Has anyone else dealt with this issue? I feel like it may come down to a script but would love to hear about any other tricks anyone is using.

Thanks in advance for any potential help with this problem!

-Cameron

4 REPLIES 4

bentoms
Esteemed Contributor
Esteemed Contributor

Hi @cpdecker,

Are you using HTTP/S or AFP/SMB distribution points?

donmontalvo
Esteemed Contributor II

man caffeinate

--
https://donmontalvo.com

cpdecker
Contributor III

@bentoms - We are using a Windows Server for the JSS so I am 99% sure it's SMB.

@donmontalvo - I thought this was a joke, but decided to type it anyway. I'll be checking caffeinate out, thanks!

JRM
Contributor

You could also setup your policy to run a script before and after.

The before script will save the settings to a temp file and then tell the computer and hard disk not to sleep

#!/bin/bash
systemsetup -getsleep > /tmp/pre-energy
systemsetup -setsleep 0
systemsetup -setharddisksleep 0

The file should look like this

Sleep: Computer sleeps Never Sleep: Display sleeps after 10 minutes Sleep: Disk sleeps after 10 minutes

Then the after script will read in the setting from the saved file and reset them back to their original values. Then remove the saved temp file.

#!/bin/bash
if [ "`cat /tmp/pre-energy | grep Computer | awk '{print $4}'`" == "Never" ]; then
  preNRG_Computer=0
else 
  preNRG_Computer=`cat /tmp/pre-energy | grep Computer | awk '{print $5}'`
fi

if [ "`cat /tmp/pre-energy | grep Dispaly | awk '{print $4}'`" == "Never" ]; then
  preNRG_Dispaly=0
else 
  preNRG_Dispaly=`cat /tmp/pre-energy | grep Dispaly | awk '{print $5}'`
fi

if [ "`cat /tmp/pre-energy | grep Disk | awk '{print $4}'`" == "Never" ]; then
  preNRG_Disk=0
else 
  preNRG_Disk=`cat /tmp/pre-energy | grep Disk | awk '{print $5}'`
fi

systemsetup -setsleep $preNRG_Computer
systemsetup -setdisplaysleep $preNRG_Dispaly
systemsetup -setharddisksleep $preNRG_Disk
rm -f /tmp/pre-energy

I have tested the commands and if statements on 10.9.3 - you may have to test and adapt it to other environments.