Running tethered-caching at startup

Created: Modified: Knowledge Base

In macOS 10.13 “High Sierra,” tethered caching has been renamed “Content Caching.” But the functionality is the same: your Mac will route network activity from USB device and also cache App Store apps locally on the Mac. This is a great feature and we highly recommend using it. Setup is extremely simple: Open your Mac’s System Preferences, then Sharing. Check the box for Content Caching. screen-shot-2017-11-18-at-10-55-50-pm That’s it. Devices will be tethered and your Mac will cache any installed apps.

  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. screen-shot-2017-04-07-at-12-27-01-pm Next you need to make the document executable. Open the Terminal, type the following, but do not press return yet:

chmod u+x

“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. screen-shot-2017-04-07-at-2-41-44-pm 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:

export EDITOR=nano

Next, let’s edit the Mac’s rules for deciding whether it should ask you for your admin password.

sudo visudo

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. screen-shot-2017-04-07-at-12-15-53-pm 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. loginitems 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.

Validation

Reboot your Mac and see what happens. The Terminal should launch and start the service without prompts. Yay!

screen-shot-2017-04-07-at-2-46-31-pmAbout GroundControl

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.