Created
November 10, 2019 08:25
-
-
Save niw/e3e5e2a50b0d87d66d836f78b2ed2459 to your computer and use it in GitHub Desktop.
Create a blank configuration profile.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
readonly PLIST_BUDDY=/usr/libexec/PlistBuddy | |
while getopts "i:h" opts; do | |
case $opts in | |
i) | |
IDENTIFIER=$OPTARG | |
;; | |
h) | |
echo "Usage: $0 [-h] -i identifier name" | |
echo " -h Show this help message" | |
echo " -i The reverse-DNS style identifier" | |
exit 0 | |
;; | |
esac | |
done | |
shift $((OPTIND - 1)) | |
readonly IDENTIFIER | |
if [[ -z $IDENTIFIER ]]; then | |
echo "Missing identifier." >&2 | |
exit 1 | |
fi | |
readonly NAME=$1 | |
if [[ -z $NAME ]]; then | |
echo "No name specified." >&2 | |
exit 1 | |
fi | |
readonly OUTPUT="$NAME.mobileconfig" | |
# See <https://developer.apple.com/documentation/devicemanagement/using_configuration_profiles> | |
$PLIST_BUDDY -c "Add :PayloadUUID string $(uuidgen)" $OUTPUT | |
$PLIST_BUDDY -c "Add :PayloadIdentifier string $IDENTIFIER" $OUTPUT | |
$PLIST_BUDDY -c "Add :PayloadType string Configuration" $OUTPUT | |
$PLIST_BUDDY -c "Add :PayloadVersion integer 1" $OUTPUT | |
$PLIST_BUDDY -c "Add :PayloadDisplayName string $NAME" $OUTPUT | |
$PLIST_BUDDY -c "Add :PayloadContent:PayloadUUID string $(uuidgen)" $OUTPUT | |
$PLIST_BUDDY -c "Add :PayloadContent:PayloadIdentifier string $IDENTIFIER" $OUTPUT | |
$PLIST_BUDDY -c "Add :PayloadContent:PayloadType string sample" $OUTPUT | |
$PLIST_BUDDY -c "Add :PayloadContent:PayloadVersion integer 1" $OUTPUT | |
echo "$OUTPUT created." | |
echo "Add each profile specified key in the PayloadContent dictionary." | |
echo "See https://developer.apple.com/documentation/devicemanagement/profile-specific_payload_keys" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment