Last active
March 25, 2025 09:50
-
-
Save jlehikoinen/28ec2336f82110829868931543b4ed95 to your computer and use it in GitHub Desktop.
Remove signature from Configuration Profile using Quick Action
This file contains hidden or 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
# Automator > Quick Action | |
# Workflow receives current "files or folders" in "Finder" | |
# Add "Run Shell Script" action | |
# Copy script below to "Run Shell Script" window | |
# Replace <text-editor-app> at row 36 with your preferred text editor app | |
# Save quick action as: "Remove signature from Profile & open in <app>" | |
# Quick Actions live in: ~/Library/Services | |
# Target folder | |
dest_dir="$HOME/Desktop" | |
while read -r file; do | |
filename="${file##*/}" | |
filename="${filename%.*}" | |
ext="${file##*.}" | |
if [[ $ext != "mobileconfig" ]]; then | |
/usr/bin/osascript -e "display alert \"Error: Only .mobileconfig files supported\"" | |
exit 1 | |
fi | |
if [[ -f "$dest_dir"/"${filename}_unsigned.mobileconfig" ]]; then | |
/usr/bin/osascript -e "display alert \"Error: Target file already exists\"" | |
exit 1 | |
fi | |
/usr/bin/security cms -D -i "$file" | /usr/bin/xmllint --format - > "$dest_dir"/"$filename"_unsigned.mobileconfig | |
if [[ $? -ne 0 ]]; then | |
/usr/bin/osascript -e "display alert \"Failed to remove signature from Profile\"" | |
/bin/rm "$filename"_unsigned.mobileconfig | |
exit 1 | |
fi | |
# Change text editor here | |
/usr/bin/open -a <text-editor-app> "$dest_dir"/"$filename"_unsigned.mobileconfig | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment