Skip to content

Instantly share code, notes, and snippets.

@olegoid
Last active Nov 19, 2015
Embed
What would you like to do?
#!/bin/sh
IPA=$1
DIR=$(dirname "${IPA}")
TEMPDIR=${DIR}/tmp
BACKUP=${IPA}_backup
EXTENSION="${IPA##*.}"
# Verify user input
if [ "$IPA" == "" ]; then
echo "Provide path to *.ipa file"
exit 0
elif [[ -d $IPA ]]; then
echo "Provided path is invalid"
exit 0
elif [[ $EXTENSION != "ipa" ]]; then
echo "Provided file is not *.ipa"
exit 0
fi
# Create *.ipa backup
mkdir $BACKUP
cp $IPA $BACKUP
# Change *.ipa extension to *.zip
mv -v $IPA ${IPA%.ipa}.zip
# Create temporary directory
mkdir $TEMPDIR
# Unzip file to tmp directory
unzip ${IPA%.ipa} -d $TEMPDIR
# Remove zip archive
rm ${IPA%.ipa}.zip
# Compress Payload folder
PAYLOAD=$TEMPDIR/'Payload'
zip -r $PAYLOAD.zip $PAYLOAD
# Rename Payload zip
mv -v $PAYLOAD.zip $IPA
rm -rf $PAYLOAD
# Move ipa file from tmp folder
mv $PAYLOAD $DIR
# Delete tmp directory
rm -rf $TEMPDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment