大家好,又见面了,我是你们的朋友全栈君。
我这边使用python来编写的,基本达到了最大化程度的解耦,其他人或者其他地方都可以直接使用。先创建installMobileProfile.py
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
import commands
import os
paramsCount = len(sys.argv)
if (paramsCount != 5):
print “本文件只支持以下的四个参数同时配置,缺一不可”
print “第一个参数:描述文件的路径”
print “第二个参数:p12文件的路径”
print “第三个参数:操作系统用户的密码”
print “第四个参数:p12文件的密码”
exit()
mobileProfilePath=sys.argv[1]
p12filePath = sys.argv[2]
password = sys.argv[3]
cert_Pass = sys.argv[4]
print ‘params is:’ + mobileProfilePath + ‘ p12:’ + p12filePath + ‘ pass:’ + password + ‘ cert_Pass:’ + cert_Pass
shellCommod = “grep UUID -A1 -a ” + mobileProfilePath + “| grep -io ‘[-A-F0-9]\{36\}'”
UUID = commands.getoutput(str(shellCommod))
print “uuid is:” + UUID
homePath = commands.getoutput(“echo ~”)
output=str(homePath+”/Library/MobileDevice/Provisioning Profiles/”+UUID+”.mobileprovision”)
output1=str(homePath+”/Library/MobileDevice/Provisioning\ Profiles/”+UUID+”.mobileprovision”)
print output
if os.path.isfile(output):
print “file is founded”
print “install finished”
else:
print “file not found”
cp_commod = str(“cp ” + mobileProfilePath + ” ” + output1)
print cp_commod
print “copying file from “+mobileProfilePath+” to “+output1
os.system(cp_commod)
print “install finished”
os.system(“ls ~/Library/MobileDevice/Provisioning\ Profiles/”)
#install p12 file
keychain_Path = str(homePath+”/Library/Keychains/login.keychain”)
sh1 = str(“security default-keychain -s ” + keychain_Path)
print “shell1 is:” + sh1
os.system(sh1)
sh2 = str(“security unlock-keychain -p ” + password + ‘ ‘ + keychain_Path)
print “shell2 is:” + sh2
os.system(sh2)
sh3 = str(“security import ” + p12filePath + ” -k ” + keychain_Path + ‘ -P ‘ + cert_Pass)
print “shell3 is:” + sh3
result = commands.getoutput(sh3)
print result
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/151173.html原文链接:https://javaforall.cn