linux安装p12,用命令行安装mobileprovision和p12证书

我这边使用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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值