Skip to content

Instantly share code, notes, and snippets.

@napkindrawing
Created February 11, 2013 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save napkindrawing/4754891 to your computer and use it in GitHub Desktop.
Save napkindrawing/4754891 to your computer and use it in GitHub Desktop.
Copy an AIR app so you can run more than one instance with it's own settings & resources.
#/bin/bash
# Usage: air_app_bifurcator.sh /Applications/HipChat.app SUFFIX
APP_PATH="$1"
APP_SUFFIX="$2"
APP_PATH_NEW=`echo "$APP_PATH" | perl -lape "s|\\.app|-$APP_SUFFIX.app|"`
if [ ! -d "${APP_PATH}" ]; then
echo "Path to app ( $APP_PATH ) doesn't exist :( :( :("
exit 1
fi
if [ -z "${APP_SUFFIX}" ]; then
echo "Hey, supply a suffix as an argument to this script already"
exit 1
fi
echo "New path is: $APP_PATH_NEW"
if [ -d "${APP_PATH_NEW}" ]; then
echo "Removing current app at new path: $APP_PATH_NEW"
rm -Rf "${APP_PATH_NEW}"
fi
echo "Copying $APP_PATH to $APP_PATH_NEW"
cp -pR "${APP_PATH}" "${APP_PATH_NEW}"
echo "Rejiggering the kajigger so we're cool"
perl -i -lape "s|<id>(.*)</id>|<id>\$1${APP_SUFFIX}</id>|" "${APP_PATH_NEW}/Contents/Resources/META-INF/AIR/application.xml"
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment