Import Data Plist(s)


Auto Munki Importer uses data plists, to inform it about a URL to monitor, how to determine the final URL for the download, and to track the modification dates of the downloads.

Data plists or directories starting with an underscore (_*/ or _*.plist) will be ignored by Auto Munki Importer, regardless of whether they have the disabled key enabled or disabled.

Format

The data plist needs to contain a dictionary called autoMunkiImporter, which contains the following required keys.

Required Keys

Key

Type

Description

URLToMonitor
string

This is the URL to monitor for new versions of an application.

name
string

The name used within Munki (and as an identifier in the logs or emails from this script).

type
string

static, dynamic, or sparkle.

The above indicate what type of URL it is that is being monitored, so that the code knows how to handle it.

Please see Static, Dynamic, and Sparkle for information on each of these types, and any additional required keys.

itemToImport
string

This is the name of the item to be imported into Munki. For example My App.app. Case insensitive find is used to locate the application, so it can be anywhere in the download (even within application bundles), and wildcards are accepted.

Optional Keys

Key

Type

Description

disabled
boolean

If true, disable checking of the application. Useful if you are checking a directory of data plists and want to skip an application without removing it.

emailReports
boolean

If true, email reports will be sent on successfully importing a new application, or on a critical error (besides the initial environment checks).

fromAddress
string

Email address to send reports from. A default email address should be specified in the settings plist, but if present in the data file it will override the default.

logFile
string

Path to log file. A default log file should be specified in the settings plist, but if present in the data file it will override the default.

munkiimportOptions
string

Additional command line options to pass to munkiimport. See munkiimport --help and makepkginfo --help for available options.

Also see Munki Keys for an additional way of providing data to be incorporated into the pkginfo's generated by Munki.

toAddress
string

Email address to send reports to. A default email address should be specified in the settings plist, but if present in the data file it will override the default.

userAgent
string

Some websites return different content based on the User Agent. This key allows you to specify the user agent to use. If this key is present it will override the user agent in the settings plist.

Munki Keys

In addition to providing options to munkiimport (and in turn makepkginfo) via the munkiimportOptions key, you can at the top level of the data plist include keys that will be copied across to the pkginfo file.

This can be useful with items like pre and post scripts, so that instead of having to maintain copies of the script, you can just copy the item into the data plist like you would to a pkginfo and the script will automatically add it. Use this for items that don't typically change between versions.

Any keys at the top level of the plist will override those in the generated pkginfo. So if you say used the munkiimportOptions key and include --catalog prod, but had a catalog array at the top of the data plist that contained 2 strings (autopkg, dev) then the final pkginfo would be set to autopkg, and dev, not prod as demonstrated with the following snippets:-

munkiimportOptions key only
<dict>
	   <key>autoMunkiImporter</key>
	   <dict>
		   <key>munkiimportOptions</key>
		   <string>--catalog prod</string>
	   </dict>
</dict>
Catalog would be "prod".

munkiimportOptions key, and catalogs key
<dict>
	   <key>autoMunkiImporter</key>
	   <dict>
		   <key>munkiimportOptions</key>
		   <string>--catalog prod</string>
	   </dict>
	   <key>catalogs</key>
	   <array>
		   <string>dev</string>
	   </array>
</dict>
Catalog would be "dev" as catalogs will override munkiimportOptions.

catalogs key only
<dict>
	   <key>catalogs</key>
	   <array>
		   <string>dev</string>
	   </array>
</dict>
Catalog would be "dev".


Types

Auto Munki Importer is aware of three different ways to monitor an application. They are Static, Dynamic, and Sparkle. Each type is explained below, and an example given.

Static

Use static when the URL doesn't change between versions. This is for sites that just update the file at the same URL when a new version is released.

Example:
Google Chrome at https://dl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg.

Example "Static" Data Plist for Google Chrome
<?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">
<plist version="1.0">
<dict>
	<key>autoMunkiImporter</key>
	<dict>
		<key>URLToMonitor</key>
		<string>https://dl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg</string>
		<key>emailReports</key>
		<true/>
		<key>itemToImport</key>
		<string>Google Chrome.app</string>
		<key>name</key>
		<string>Chrome</string>
		<key>munkiimportOptions</key>
		<string>--subdirectory "apps/google"</string>
		<key>type</key>
		<string>static</string>
	</dict>
	<key>catalogs</key>
	<array>
		<string>autopkg</string>
	</array>
	<key>display_name</key>
	<string>Google Chrome Web Browser</string>
</dict>
</plist>

Dynamic

Use dynamic when the download link changes with each new version. This type allows you to search the page and its source for the download link to use. Dynamic also has an additional required and optional key. See below:-

Required Key

Key

Type

Description

downloadLinkRegex
string

This is the either the text of the download link (e.g. THIS TEXT from: <a href="http://example.com/application.dmg>THIS TEXT</a>), or a Perl compatible regular expression that searches the entire pages source.

Optional Key

Key

Type

Description

secondLinkRegex
string

Some web pages will redirect to a second page which contains the actual download. In this case this key is used to find the download. It works the same as the downloadLinkRegex key.

Example:
Adobe Flash Player at http://get.adobe.com/flashplayer/.

Example "Dynamic" Data Plist for Adobe Flash Player
<?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">
<plist version="1.0">
<dict>
	<key>autoMunkiImporter</key>
	<dict>
		<key>URLToMonitor</key>
		<string>http://get.adobe.com/flashplayer/</string>
		<key>downloadLinkRegex</key>
		<string>Download Now</string>
		<key>emailReports</key>
		<true/>
		<key>itemToImport</key>
		<string>Adobe Flash Player.pkg</string>
		<key>munkiimportOptions</key>
		<string>--subdirectory "apps/adobe"</string>
		<key>name</key>
		<string>AdobeFlashPlayer</string>
		<key>secondLinkRegex</key>
		<string>location.href\s*=\s*'(.+?)'</string>
		<key>type</key>
		<string>dynamic</string>
	</dict>
	<key>catalogs</key>
	<array>
		<string>autopkg</string>
	</array>
	<key>description</key>
	<string>Adobe Flash Player Plugin for Web Browsers</string>
	<key>display_name</key>
	<string>Adobe Flash Player</string>
</dict>
</plist>

Sparkle

Applications that use the Sparkle framework have a RSS based Appcast that list updates. This option will parse that feed for the update. To find if an application uses Sparkle run: find /path/to/application.app -name Sparkle.framework -print. To find the URL Sparkle is using, continue reading the Finding the URL section.

Example:
VLC at http://www.videolan.org with Appcast URL of http://update.videolan.org/vlc/sparkle/vlc.xml.

Example "Sparkle" Data Plist for VLC
<?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">
<plist version="1.0">
<dict>
	<key>autoMunkiImporter</key>
	<dict>
		<key>URLToMonitor</key>
		<string>http://update.videolan.org/vlc/sparkle/vlc.xml</string>
		<key>downloadLinkRegex</key>
		<string></string>
		<key>emailReports</key>
		<true/>
		<key>itemToImport</key>
		<string>VLC.app</string>
		<key>munkiimportOptions</key>
		<string>--subdirectory "apps/vlc"</string>
		<key>name</key>
		<string>VLC</string>
		<key>secondLinkRegex</key>
		<string></string>
		<key>type</key>
		<string>sparkle</string>
		<key>userAgent</key>
		<string></string>
	</dict>
	<key>catalogs</key>
	<array>
		<string>autopkg</string>
	</array>
	<key>description</key>
	<string>VLC Media Player plays a wide range of different video and audio formats.</string>
</dict>
</plist>

Finding the URL

In Safari you can right click on a link and "Copy Link", or view the pages source to determine the URL. If you have the Develop menu (Preferences -> Advanced -> Show Develop meun in menu bar) enabled, right click on an item and Inspect Element. This will show you the specific HTML behind a link.

For tricker pages, and applications using Sparkle I recommend using SquidMan.

SquidMan

SquidMan is a easy to configure and use squid proxy. You can use it to log all requests, and using this information build our data plist.

To setup SquidMan, do the following:-

  1. Download SquidMan from the above link, mount the disk image and copy the application to /Applications.
  2. Start SquidMan, and if prompted install the critical helper tool (following the prompts).
  3. If it's the first time you have run SquidMan the preference window will be shown. If not select SquidMan -> Preferences.
  4. Select the Template Tab and add the following:-
    # Don't strip query paramaters. This could mean that sensitive information appears in your logs. Use with caution!
    strip_query_terms off
  5. Click Save.
  6. Start (or restart) SquidMan. If everything has been successfully done it should now say Status: Squid is running

Configure the system to use the Squid Proxy:-

  1. System Preferences -> Network
  2. Select your primary network interface, and select Advanced
  3. Select Proxies tab
  4. Enable Web Proxy (HTTP)
    1. Set the Web proxy to localhost
    2. Set the port to 8080
  5. Repeat Step 4 for Secure Web Proxy (HTTPS)
  6. Click OK then Apply

Now that the system is using the squid proxy, you can run tail -f ~/Library/Logs/squid/squid-access.log to see what URLs are being accessed. If the application uses Sparkle, ask it to check for updates and look for what URL was used.