I wrote some code to package channel IPA and resign IPA with shell. When I run this shell in command line it works ok.
Main shell code:
#!/bin/bash
name=$1
needchannel=$2
appName="$name.app"
ipa="$name.ipa"
plistName="${name}_${needchannel}.plist"
# echo "${1} ${2} $ipa"
if [ ! -f "./Payload" ];then
# echo "not exit Payload"
unzip $ipa
chmod -R 0777 Payload
else
echo "exit Payload"
fi
cd Payload
cd $appName
ipaPath="${name}_${needchannel}.ipa"
/usr/libexec/PlistBuddy -c "set Channel $needchannel" "Channel.plist"
cd ../..
/usr/bin/codesign -f -s "iPhone Distribution: xxxx, ooo" --entitlements entitlements.plist "Payload/${appName}"
zip -rq "./app/${ipaPath}" "Payload"
PHP code:
<?php
$webid = $_GET["webid"];
$appfinder = "./app/";
$filename = "Channel_".$webid.".ipa";
if (!file_exists($appfinder.$filename))
{
$shell = "sh produceApp.sh Channel $webid";
system($shell, $status);
if( $status ){
echo "produceApp error";
var_dump($status);
return;
}
}
?>
I don't know why the shell run success in command line and fail in PHP. Can anybody help me.
Everything works except codesign.
ps:i write the shell code in php,run directly,system() return 1;like this:
<?php
$shell = "/usr/bin/codesign -f -s \"iPhone Distribution: xxx, ooo\" --entitlements entitlements.plist \"Payload/Channel.app\"";
echo "$shell";
echo "<br>";
system($shell, $status);
print_r($status);
?>
the chrome show shell is:
/usr/bin/codesign -f -s "iPhone Distribution: xxx, ooo" --entitlements entitlementds.plist "Payload/Channel.app"
and function system() return $status is 1..