Skip to content

Instantly share code, notes, and snippets.

@summer-wu
Last active November 14, 2016 12:35
Show Gist options
  • Save summer-wu/a41582ce6956c5ec4b9cf15c8b1fa873 to your computer and use it in GitHub Desktop.
Save summer-wu/a41582ce6956c5ec4b9cf15c8b1fa873 to your computer and use it in GitHub Desktop.
decrypt all mobileprovision files
#!/bin/bash
#usagge:
#place this file at ~/Library/MobileDevice/Provisioning Profiles
#chmod +x ./decrypt.sh
#./decrypt.sh
i=1 #loop index
decryptPPFileCommand="security cms -D -i "
for ppfile in *.mobileprovision; do
echo $i:$ppfile #print current index
echo '>>>begin to decrypt' $ppfile
$decryptPPFileCommand "$ppfile" > temp.plist #将ppfile转换为plist文件
nameline=$(plutil -p temp.plist |env grep '"Name"') #读取plist文件
nameline=$(echo $nameline|sed -e 's/[^A-Za-z0-9._-]/_/g') #sanitize filename因为有可能有星号 http://serverfault.com/questions/348482/how-to-remove-invalid-characters-from-filenames
nameAfterDeleteQuote=${nameline//\"/} #移除双引号
name=${nameAfterDeleteQuote:10}
mv temp.plist "${name}.plist"
echo '>>>already create' "${name}.plist"
echo
((i+=1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment