Apple’s new tethered-caching service is an extremely powerful new addition to iOS management, at least if you are using Macs to aide your deployments. Once you get it running properly (see this article), you’ll want it running all the time. But it is not quite obvious how to get the service to launch at startup. The service actually requires an interactive Terminal, so normal launchd daemons can’t be used.
Here’s the solution we are using. I’m assuming you are a little familiar with the Mac’s command-line interface here, but not too familiar.
Step 1: Create a Terminal command document
Use any text editor and paste the following two lines:
#!/bin/sh sudo /usr/bin/tethered-caching
If you are using TextEdit, click Format > Make Plain Text. (Thanks Allison!)
Save this document anywhere your hard drive, using the extension “.command". For example, I used tethered-caching.command as the filename.
Next you need to make the document executable. Open the Terminal, type the following, but do not press return yet:
“u” is for user, and “x” is for executable. Make sure there’s a space after the ‘x’.
Now drag the command file you created into the Terminal window. Terminal will helpfully type the path to the file for you.
Press return to run the command, making your command document executable.
Double-click your document, and the Terminal app will open and run the command. You will be prompted you for your admin password, because tethered-caching runs as root.
Close the window because we’re going to get rid of that password prompt next.
Step 2: Remove the password requirement
Using the Terminal, let’s first set our preference for the simple text editor nano, instead of the more difficult vi. (If you like vi skip this part.) Type the following:
Next, let’s edit the Mac’s rules for deciding whether it should ask you for your admin password.
Type your admin password if prompted (it won’t show on the screen).
You’ll then see the contents of the file /etc/sudoers. All we want to do is (1) tap the down arrow until you are at the bottom, and (2) add the following line:
aaron ALL=(ALL) NOPASSWD: /usr/bin/tethered-caching
If your name is not “Aaron” then substitute your Mac username instead.
Save the file by typing Control+X, then answer Y, then press the Return key.
Now, test this by double-clicking on the command document you created in Step 1. It should open a new Terminal window and run the tethered-caching service without a prompt. Yes? You are now ready for…
Step 3: Launching at Login
Open System Preferences > Users & Groups > (your user) > Login Items. Drag your saved command document into the list.
Finally, while you are in that system pref pane, make sure that your Mac is set to automatically log in as a user on boot. It probably is already.
Reboot your Mac and see what happens. The Terminal should launch and start the service without prompts. Yay!
GroundControl is a breakthrough tool for simplifying iOS management and imaging devices, especially at large scale. We love tricks like this because it makes our customers happy. Check us out at groundctl.com.