Sometimes you want to add a configuration profile to a Mac during imaging.
Here's one way. (I updated the article thanks to a suggestion from @macjutsu - I originally placed the mobileconfig file in /var/tmp, but we like placing items in /Library/<Your Organization's Name>). And I added a reference to @timsutton's Make Profile Pkg thanks to a suggestion from @daz_wallace.
Get the Configuration profile into place.
- In Jamf Pro, create the configuration profile if it's not already created.
- Scope the configuration profile to the Mac computers that will receive this configuration profile, otherwise Jamf Pro will remove the configuration profile when the Mac is enrolled!
- Click Download to download the configuration profile.
- The Profiles preference automatically opens and asks if you want to install the configuration profile. Click Cancel, because you just want to download it, not install it.
- Alternative to Composer: You could use @timsutton's Make Profile Pkg then skip to the "Test" section, then complete the "Upload to Jamf Pro and add to a configuration" section at the end of the article.
If you don't already have a folder for organzational assets in /Library, create one now.
- In Finder, choose Go > Go to Folder.
- In the "Go to the folder" window, enter /Library, then click Go.
- Choose File > New Folder (Shift-Command-N).
- Enter adminstrator credentials then click OK.
- Change the new folder's name (probably "untitled folder") to be your organization's name (press Return to start renaming, enter text, press Return again to save the change, enter adminstrator credentials when prompted, then click OK). Hint: consider not using a space character in the name; if you use a space in the name you'll need to always remember to escape the space with a backspace.
- Open your new folder, and keep this Finder window open.
If the /Library/<Your Organization's Name> folder isn't already open, open it now.
- In Finder, choose Go > Go to Folder.
- In the "Go to the folder" window, enter /Library/Zabazakka, then click Go. Of course, your organization's name is probably not Zabazakka, so replace it with your organzation's name.
Copy the file from ~/Downloads to /Library/<Your Organization's Name>.
- In Finder, choose File > New Finder Findow (Command-N), then choose Go > Downloads (Option-Command-L).
- Optional: If you have many files in Downloads, click the Column view icon in the Finder toolbar, then click the Date Modified column to change the sort order to easily find the .mobileconfig file.
- Drag the .mobileconfig file you just downloaded from the Downloads folder to the /Library/<Your Organization's Name> folder.
- Be sure to keep the /Library/<Your Organization's Name> Finder window open for the next steps.
Use Composer to package it up along with a postinstall script.
- Open Composer.
- If you see the window titled "Choose a method to create your package," click Cancel.
- Move windows around so you can see both the sidebar of Composer and the /Library/<Your Organization's Name> Finder window.
- In Finder, drag the mobileconfig file from the /Library/<Your Organization's Name> folder to the sidebar of Composer.
- In Composer, in the Sources section, select the new package that was created. It has the same name as the mobileconfig file you just dragged.
- Click the disclosure triangle for the new package.
- Right-click Scripts, choose Add Shell Script, then choose postinstall.
- In the Composer sidebar, select the postinstall script.
- Edit the script in the main window of Composer. If the path or filename for the mobileconfig file has a space, be sure to use the backslash to the name to protect the space character. Add a line like the following:
Hint: When you drag the mobileconfig file from Finder to Terminal, the path and filename will be displayed with any special characters (like the space character) properly escaped with a backslash. If you drag the mobileconfig file from Finder to the script editor in Composer, the space character won't be escaped with the backslash.
/usr/bin/profiles -I -F /Library/My Organization Name/my special config.mobileconfig
- Optional: After the /usr/bin/profiles line, enter a line to remove the mobileconfig file from /Library/<Your Organization's Name>, like
rm -rf /Library/My Organization Name/my special config.mobileconfig
- Select your package in the Sources section of the Composer sidebar.
- At the "Do you want to save changes" dialog, click Save.
- Click Build as Package in the toolbar.
- Specify the destination to save the package, then click Save.
- Copy the package to a test Mac.
- Open the package and complete the installation.
- Open the Profiles preferences and confirm that the configuration profile has been installed.
Don't worry that it's listed as Unverified.
Upload to Jamf Pro and add to a configuration.
- In Casper Admin, drag the package to your main repository.
- Double-click the package in the main repository.
- Click the General tab.
- Choose a category.
- Click the Options tab.
- Choose a priority. I like setting the operating system as 1, and a Wi-Fi profile as 2. It's up to you of course.
- Select the checkbox "Install on boot drive after imaging".
- Click OK to close the window.
- Save (Command-S) your work in Composer.
- Drag the new package into a configuration that you use with Casper Imaging.
- If you already have Casper Imaging open, in Casper Imaging click Refresh in the toolbar.
Bonus: If you have a Developer ID, don't forget to sign your QuickAdd package.