Skip to content
Graham Pugh edited this page Mar 6, 2024 · 7 revisions

jamf-upload.sh is a wrapper script for utilising the JamfUploader AutoPkg processors without recipes.

My primary use-case for this is testing new features and bugs in the processors, but it could be used for standalone workflows, as a replacement for the Standalone upload scripts.

Use Requires AutoPkg to be installed, but it shouldn't need to be configured. However, you do need to supply credentials to interact with Jamf Pro, either using the --url, --user and --pass options, or by pointing to a prefs file containing those values (e.g. an existing AutoPkg prefs file), with the --prefs option.

Here are the possible options:

Usage: 
./jamf-upload.sh [object_type] [--help] [arguments]
Valid object types:
    category
    group | computergroup
    profile | computerprofile
    ea | extensionattribute
    logflush
    macapp
    patch
    pkg | package
    policy
    restriction | softwarerestriction
    script
    slack
    teams
Arguments:
    --prefs <path>          Inherit AutoPkg prefs file provided by the full path to the file
    -v[vvv]                 Set value of verbosity
    --url <JSS_URL>         The Jamf Pro URL
    --user <API_USERNAME>   The API username
    --pass <API_PASSWORD>   The API user's password
    --recipe-dir <RECIPE_DIR>
Category arguments:
    --name <string>         The name
    --priority <int>        The priority
    --replace               Replace existing item
Computer Group arguments:
    --name <string>         The name
    --template <path>       XML template
    --key X=Y               Substitutable values in the template. Multiple values can be supplied
    --replace               Replace existing item
Computer Profile arguments:
    --name <string>         The name
    --template <path>       XML template
    --payload <path>        A profile payload
    --mobileconfig <path>   A mobileconfig file
    --identifier <string>   Identifier for the profile
    --category <string>     The category. Must exist.
    --organization <string> Organisation for the profile
    --description <string>  Description for the profile
    --computergroup <str>   Computer Group to set as target in the profile
    --key X=Y               Substitutable values in the script. Multiple values can be supplied
    --replace               Replace existing item
Dock Item arguments:
    --name <string>         The name
    --type <string>         Type of Dock Item - either 'App', 'File' or 'Folder'
    --path <string>         Path of Dock Item - e.g. 'file:///Applications/Safari.app/'
    --replace               Replace existing item
Extension Attribute arguments:
    --name <string>         The name
    --script <path>         Full path of the script to be uploaded
    --key X=Y               Substitutable values in the template. Multiple values can be supplied
    --replace               Replace existing item
Mac App Store App arguments:
    --name <string>         The name
    --template <path>       XML template
    --replace               Replace existing item
Package arguments:
    --name <string>         The name
    --pkg <path>            Full path to the package to upload
    --priority <int>        The priority
    --category <string>     The category. Must exist.
    --smb-url <url>         URL of the fileshare distribution point (on premises Jamf Pro only)
    --smb-user <SMB_USERNAME>
                            Username with share access
    --smb_pass <SMB_PASSWORD>
                            Password of the user
    --info <string>         Pkg information field
    --notes <string>        Pkg notes field
    --reboot_required       Set the 'reboot required' option
    --os-requirement <string>
                            Set OS requirement for the pkg
    --required-processor <string>
                            Set CPU type requirement for the pkg
    --send-notification     Set to send a notification when the package is installed
    --replace-pkg-metadata  Set to replace the pkg metadata if no package is uploaded
    --replace               Replace existing item
    --jcds                  Deprecated. Does nothing.
    --jcds2                 Use v3 API for package upload to JCDS
    --aws                   Use aws-cli tools to upload package to an AWS S3 CDP. Requires aws-cli tools to be installed.
Policy arguments:
    --name <string>         The name
    --template <path>       XML template
    --icon <path>           Full path to an icon file for Self Service policies
    --key X=Y               Substitutable values in the template. Multiple values can be supplied
    --replace               Replace existing item
    --replace-icon          Set to replace the existing icon if it has the same name
Policy Delete arguments:
    --name <string>         The policy name
Policy Log Flush arguments:
    --name <string>         The policy name
    --interval              The log flush interval
Patch Policy arguments:
    --name <string>         The patch policy name
    --pkg <path>            Name of the package to uplaod
    --version <string>      The package (or app) version
    --title <string>        The patch software title
    --template <path>       XML template
    --policy <string>       Name of an existing policy containing the desired icon for the patch policy
    --replace               Replace existing item
Script arguments:
    --name <string>         The name
    --script <path>         Full path of the script to be uploaded
    --key X=Y               Substitutable values in the script. Multiple values can be supplied
    --script_parameter[4-11]
                            Script parameter labels 
    --replace               Replace existing item
Software Restriction arguments
    --name <string>         The name
    --template <path>       XML template
    --process-name          Process name to restrict
    --display-message       Message to display to users when the restriction is invoked
    --match-exact-process-name
                            Match only the exact process name if True
    --send-notification     Send a notification when the restriction is invoked if True
    --kill-process          Kill the process when the restriction is invoked if True
    --delete-executable     Delete the executable when the restriction is invoked if True
    --replace               Replace existing item
Slack arguments:
    --name <string>         The name
    --policy-category <string>
                            The POLICY_CATEGORY
    --pkg-category <string> The PKG_CATEGORY
    --pkg_name <string>     The package name
    --version <string>      The package (or app) version
    --pkg-uploaded          Pretends that a package was uploaded (sets a value to jamfpackageuploader_summary_result)
    --policy-uploaded       Pretends that a policy was uploaded (sets a value to jamfpolicyuploader_summary_result)
    --slack-url <url>       The slack_webhook_url
    --slack-user <string>   The Slack user to display
    --icon <url>        The Slack icon URL
    --channel <string>      The Slack channel to post to
    --emoji <string>        the Slack icon emoji
Teams arguments:
    --name <string>         The name
    --policy-category <string>
                            The POLICY_CATEGORY
    --pkg-category <string> The PKG_CATEGORY
    --patch_name <string>   The patch policy name
    --pkg_name <string>     The package name
    --version <string>      The package (or app) version
    --patch-uploaded        Pretends that a patch was updated (sets a value to jamfpatchuploader_summary_result)
    --pkg-uploaded          Pretends that a package was uploaded (sets a value to jamfpackageuploader_summary_result)
    --policy-uploaded       Pretends that a policy was uploaded (sets a value to jamfpolicyuploader_summary_result)
    --teams-url <url>       The teams_webhook_url
    --teams-user <string>   The Teams user to display
    --icon <url>        The Slack icon URL

Examples:

Uploading a category

As a minimum, the --prefs need to have the Jamf Pro Server credentials in it.

./jamf-upload.sh category \
    --prefs ~/Library/Preferences/com.github.autopkg.plist \
    --name JamfUploadTest \
    --priority 18 \
    -vv

Uploading a package

./jamf-upload.sh pkg \
    --prefs ~/Library/Preferences/com.github.autopkg.plist \
    --pkg python_recommended_signed-3.9.5.09222021234106.pkg \
    --category JamfUploadTest \
    -v

Uploading a computer profile

In this example, we are supplying a template (ProfileTemplate-test-users.xml), and a payload .plist file (com.bombich.ccc.plist). Note that we need to supply a --recipe-dir parameter, even though we are not using a recipe. This acts as a fake repo base directory, under which the JamfUploader processors will look for the templates that are specified. Otherwise you may be able to supply the full path to each template:

./jamf-upload.sh profile \
    --prefs ~/Library/Preferences/com.github.autopkg.plist \
    --name "Carbon Copy Cloner" \
    --recipe-dir /path/to/folder-with-templates \
    --template ProfileTemplate-test-users.xml \
    --payload com.bombich.ccc.plist \
    --identifier com.bombich.ccc \
    --category JamfUploadTest \
    --organization "Graham Pugh Inc." \
    --description "Amazing test profile" \
    --computergroup "Testing" \
    -vv \
    --key REGISTRATION_CODE="FAKE-CODE" \
    --key REGISTRATION_EMAIL="no@yes.com" \
    --key REGISTRATION_NAME="MyCorp License Administration" \
    --key REGISTRATION_PRODUCT_NAME='Carbon Copy Cloner 6 Volume License' \
    --replace

Uploading a software restriction

In this example, we are supplying a template (RestrictionTemplate-singlegroup.xml). Note that we need to supply a --recipe-dir parameter, even though we are not using a recipe. This acts as a fake repo base directory, under which the JamfUploader processors will look for the templates that are specified. Otherwise you may be able to supply the full path to each template:

./jamf-upload.sh restriction \
    --prefs ~/Library/Preferences/com.github.autopkg.plist \
    --name "Restrict Carbon Copy Cloner" \
    --recipe-dir /path/to/folder-with-templates \
    --template RestrictionTemplate-singlegroup.xml \
    --process_name "Carbon Copy Cloner" \
    --display_message "Carbon Copy Cloner is not allowed." \
    --match_exact_process_name \
    --kill_process \
    --computergroup Testing \
    -vvv \
    --replace