What's the problem?
A work-in-progress solution
What's the problem?
Munki is a great tool for keeping laptops and desktops up to date. For normal laptops, I basically have Munki check in every hour or so (as it does by default) but not bother the user for 14 days. So unattended installs can happen in the background and then twice a month users can take care of logout/reboot updates. For desktops, I have a substitute Launch Daemon run once a day before school starts to keep those machines up to date and then not bother the users throughout the day.
The problem comes with laptop carts. The machines in those carts usually have their lids shut and don't get used often enough or long enough to get all the updates via Munki. The other half of that problem is Apple making it so laptops always go to sleep when the lid is closed (unless the laptop is plugged into an external monitor).
I've done a lot of research and experimentation, and this is the best thing I could come up with (haven't had any luck with Munki Overnight and don't want to use InsomniaX while they're still figuring out licensing/distribution). Since I haven't found any working, step-by-step tutorials on how to do this, I figure it's better to have something than nothing. If I get a more streamlined process, I'll update this post or create a new post.
Some nuances I've discovered about NoSleep based on research and trial/error:
- It isn't optimized for El Capitan, because it still writes the extension to /System/Library/Extensions instead of just /Library/Extensions. Apparently, that's okay according to OS X 10.11 El Capitan: The Ars Technica Review (you can add and remove your own custom extensions but can't touch the ones that are already in there) and my own testing, but it's still good practice to avoid that directory altogether. In production, I'm running this on only Yosemite clients, so I don't know if NoSleep actually functions well in El Capitan. It runs fine on El Capitan clients.
- In addition to preventing sleep, it also appears to prevent scheduled shutdowns. Manual reboots seem to work.
- When NoSleep is active, closing the laptop lid will still turn off the laptop screen (I believe so anyway, based on the lighted Apple logo turning off) even though the laptop is still on. I'm hoping (but haven't done extensive testing yet) this will stop the laptop from overheating (since it's on but inactive and with the screen not on). The laptops seem to heat up a bit, but not too much. Definitely no overheating issues.
- There's an optional command-line utility you can install when you go through the install wizard, but it doesn't seem to have options to enable NoSleep the same way you can through point-and-click on the taskbar icon. (I futzed around with the CLI tool... maybe I'm missing something?) Honestly, I don't mind manually enabling it on a bunch of laptops if it means I don't have to manually periodically run Munki on them.
version: you may have to manually enable NoSleep once on each client, but it will still save you time in the long run.
A work-in-progress solution
Download the latest release of NoSleep, which is a kernel extension that can prevent the Mac laptop from going to sleep when the lid is closed. Import its package into Munki to distribute out to client machines in the laptop carts.
On each laptop (haven't found a way to automate this yet), launch up and enable NoSleep.
Once NoSleep is working, the laptop is basically just on all the time (with the screen off when the lid is closed), so you can create a modified version (keep the original but just unload it) of the roughly-once-an-hour Launch Daemon so it runs once a day.
Here's an example /Library/LaunchDaemons/com.googlecode.munki.managedsoftwareupdate-check.revised.plist you can package up and distribute out to clients:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
This basically tells the laptop to run Munki once in the morning some time after 6:10am.
Unload the original:
sudo launchctl unload -w /Library/LaunchDaemons/com.googlecode.munki.managedsoftwareupdate-check.plist
and load up your revised one:
sudo launchctl load -w /Library/LaunchDaemons/com.googlecode.munki.managedsoftwareupdate-check.revised.plist
You may also want to install some kind of auto-logout script (that nopkg .plist will log out normal users after 5 minutes of inactivity, but you can tweak the logout time). If you need to force a logout (for example, with a guest user account), you can use this command:
osascript -e 'tell application "loginwindow" to «event aevtrlgo»'
With your laptops not going to sleep and then checking in with Munki once in the morning at the login screen, they should be good and updated.
P.S. I haven't had a chance to test this out extensively yet, but Greg Neagle (primary author of Munki) has confirmed that (as of this writing) invoking managedsoftwarecenter from the command line does not check for battery life (Managed Software Center will prompt the user about whether to continue or not on low battery), so I've toyed around with using a modified version of the MunkiOvernight script to check the battery before running the update.
P.P.S. Upgrades from Yosemite to El Capitan don't often happen smoothly with the lid shut and the NoSleep extension activated. I would highly recommend doing that upgrade with the lid open.