Using the Jamf Pro API to download IPA files from a JCDS2 distribution point
文章介绍如何使用Jamf Pro API从JCDS2分发点下载IPA文件,并提供一个脚本,支持用户账户或API客户端认证,可获取IPA列表、下载链接,并验证MD5哈希以确保文件完整性。 2025-5-8 20:9:19 Author: derflounder.wordpress.com(查看原文) 阅读量:12 收藏

Home > Jamf Cloud Distribution Service, Jamf Pro API, Jamf Pro Classic API, Scripting > Using the Jamf Pro API to download IPA files from a JCDS2 distribution point

Using the Jamf Pro API to download IPA files from a JCDS2 distribution point

A while back, I wrote about how you could use the Jamf Pro API to download installer packages from a JCDS2 distribution point

However, installer packages are not the only items which may be stored on a JCDS2 distribution point. The IPA files used by in-house iOS, iPadOS and tvOS devices may also be stored for distribution on a JCDS2 distribution point. IPA files stored on a JCDS2 distribution point can be accessed for download in the same way that installer packages can.

For those who want to use this capability, I’ve written a script which uses the Jamf Pro Classic API and Jamf Pro API to get the list of IPA files on a Jamf Pro server, retrieve the associated download links and download the IPA files to a directory on my Mac. For more details, please see below the jump.

Pre-requisites:

If setting up a specific Jamf Pro user account for this purpose with limited rights, here are the required API privileges for the account on the Jamf Pro server:

Jamf Pro Server Objects:

  • Mobile Device Apps: Read
  • Jamf Content Distribution Server Files: Read

For authentication, the script can accept manual input or values stored in a ~/Library/Preferences/com.github.jamfpro-info.plist file. The plist file can be created by running the following commands and substituting your own values where appropriate:

To store the Jamf Pro URL in the plist file:


To store the account username in the plist file:


defaults write com.github.jamfpro-info jamfpro_user account_username_goes_here

To store the account password in the plist file:


defaults write com.github.jamfpro-info jamfpro_password account_password_goes_here

Usage: 

/path/to/Jamf_Pro_JCDS_Mobile_InHouseIPA_Download.sh

The script takes the following actions:

  1. Creates a download directory if none has been specified in the script.
  2. Uses the Jamf Pro Classic API to download the list of mobile device applications from the Jamf Pro server.
  3. Gets the Jamf Pro ID numbers for the individual IPA files.
  4. Uses the Jamf Pro Classic API to get the names of the individual IPA files.
  5. Uses the Jamf Pro API to get the MD5 hash of the individual IPA files.
  6. Checks to see if a file with a matching name and MD5 hash exists in the download directory.
  7. If a file with a matching name and MD5 hash exists in the download directory, display a message that the file exists in the download directory.
  8. If a file with a matching name and MD5 hash does not exist in the download directory, use the Jamf Pro API to query the JCDS2 distribution point for the download URL of the IPA file and download the IPA file.

The script should provide output similar to this:

Downloading new copies of the IPA files where no copies currently exist:


username@computername ~ % /Users/username/Jamf_Pro_JCDS_Mobile_InHouseIPA_Download.sh
A location to store downloaded IPA files has not been specified.
Downloaded IPA files will be stored in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Please enter your Jamf Pro server URL : https://jamfpro.server.here
Please enter your Jamf Pro user account : apiuser
Please enter the password for the apiuser account:
/var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo exists but is empty. Using existing directory for downloading IPA files.
Downloading AIM 1.0.ipa to /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
######################################################################################################## 100.0%
AIM 1.0.ipa is available in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Downloading AMP 2.3.ipa to /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
######################################################################################################## 100.0%
AMP 2.3.ipa is available in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Downloading Barcodes 1.1.ipa to /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
######################################################################################################## 100.0%
Barcodes 1.1.ipa is available in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Downloading Battleship 1.0.6.ipa to /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
######################################################################################################## 100.0%
Battleship 1.0.6.ipa is available in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
username@computername ~ %

Verifying existing copies of the IPA files exist and have MD5 hashes that match the IPA files stored in Jamf Pro:


username@computername ~ % /Users/username/Jamf_Pro_JCDS_Mobile_InHouseIPA_Download.sh
Please enter your Jamf Pro server URL : https://jamfpro.server.here
Please enter your Jamf Pro user account : apiuser
Please enter the password for the apiuser account:
AIM 1.0.ipa found in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Checking MD5 hash of AIM 1.0.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo to verify match with AIM 1.0.ipa on https://jamfpro.server.here…
MD5 hash of AIM 1.0.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo matches AIM 1.0.ipa on https://jamfpro.server.here.
AIM 1.0.ipa is available in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
AMP 2.3.ipa found in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Checking MD5 hash of AMP 2.3.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo to verify match with AMP 2.3.ipa on https://jamfpro.server.here…
MD5 hash of AMP 2.3.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo matches AMP 2.3.ipa on https://jamfpro.server.here.
AMP 2.3.ipa is available in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Barcodes 1.1.ipa found in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Checking MD5 hash of Barcodes 1.1.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo to verify match with Barcodes 1.1.ipa on https://jamfpro.server.here…
MD5 hash of Barcodes 1.1.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo matches Barcodes 1.1.ipa on https://jamfpro.server.here.
Barcodes 1.1.ipa is available in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Battleship 1.0.6.ipa found in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Checking MD5 hash of Battleship 1.0.6.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo to verify match with Battleship 1.0.6.ipa on https://jamfpro.server.here…
MD5 hash of Battleship 1.0.6.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo matches Battleship 1.0.6.ipa on https://jamfpro.server.here.
Battleship 1.0.6.ipa is available in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
username@computername ~ %

Verifying existing copies of the IPA files exist and detecting copies that do not have MD5 hashes that match the IPA files stored in Jamf Pro:


username@computername ~ % /Users/username/Jamf_Pro_JCDS_Mobile_InHouseIPA_Download.sh
Please enter your Jamf Pro server URL : https://jamfpro.server.here
Please enter your Jamf Pro user account : apiuser
Please enter the password for the apiuser account:
AIM 1.0.ipa found in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Checking MD5 hash of AIM 1.0.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo to verify match with AIM 1.0.ipa on https://jamfpro.server.here…
MD5 hash of AIM 1.0.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo matches AIM 1.0.ipa on https://jamfpro.server.here.
AIM 1.0.ipa is available in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
AMP 2.3.ipa found in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Checking MD5 hash of AMP 2.3.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo to verify match with AMP 2.3.ipa on https://jamfpro.server.here…
MD5 hash of AMP 2.3.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo matches AMP 2.3.ipa on https://jamfpro.server.here.
AMP 2.3.ipa is available in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Barcodes 1.1.ipa found in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Checking MD5 hash of Barcodes 1.1.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo to verify match with Barcodes 1.1.ipa on https://jamfpro.server.here…
MD5 hash of Barcodes 1.1.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo does not match Barcodes 1.1.ipa on https://jamfpro.server.here.
Deleting Barcodes 1.1.ipa from /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Downloading Barcodes 1.1.ipa to /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
######################################################################################################## 100.0%
Barcodes 1.1.ipa is available in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Battleship 1.0.6.ipa found in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
Checking MD5 hash of Battleship 1.0.6.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo to verify match with Battleship 1.0.6.ipa on https://jamfpro.server.here…
MD5 hash of Battleship 1.0.6.ipa in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo matches Battleship 1.0.6.ipa on https://jamfpro.server.here.
Battleship 1.0.6.ipa is available in /var/folders/zh/5bw3hvb93kdb3nwmwfjkhgsw0000gp/T/tmp.MAKKW8O0oo.
username@computername ~ %

This script is available from GitHub at the following location:

https://github.com/rtrouton/rtrouton_scripts/tree/main/rtrouton_scripts/Casper_Scripts/Jamf_Pro_JCDS_Mobile_InHouseIPA_Download/user_account_authentication

A version which uses API client authentication is available from GitHub at the following location:

https://github.com/rtrouton/rtrouton_scripts/tree/main/rtrouton_scripts/Casper_Scripts/Jamf_Pro_JCDS_Mobile_InHouseIPA_Download/API_client_authentication

Both scripts can be accessed via the following link:

https://github.com/rtrouton/rtrouton_scripts/tree/main/rtrouton_scripts/Casper_Scripts/Jamf_Pro_JCDS_Mobile_InHouseIPA_Download


文章来源: https://derflounder.wordpress.com/2025/05/08/using-the-jamf-pro-api-to-download-ipa-files-from-a-jcds2-distribution-point/
如有侵权请联系:admin#unsafe.sh