Skip to content

Instantly share code, notes, and snippets.

@lacostej
Created July 10, 2013 01:03
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lacostej/5962700 to your computer and use it in GitHub Desktop.
Save lacostej/5962700 to your computer and use it in GitHub Desktop.
A script to install Unity3d automatically from the command line given a dmg file. The resulting file is stored under /Applications/Unity$VERSION
dmg=$1
# A script to install Unity3d automatically from the command line given a dmg file.
# The resulting file is stored under /Applications/Unity$VERSION
# check assumptions
unityhome=/Applications/Unity
if [[ -d "$unityhome" ]]; then
echo "ERROR: $unityhome already present"
exit -1
fi
tempfoo=`basename $0`
TMPFILE=`mktemp /tmp/${tempfoo}.XXXXXX` || exit 1
hdiutil verify $dmg
hdiutil mount -readonly -nobrowse -plist $dmg > $TMPFILE
vol=`grep Volumes $TMPFILE | sed -e 's/.*>\(.*\)<\/.*/\1/'`
pkg=`ls -1 "$vol"/*.pkg`
sudo installer -pkg "$pkg" -target /
hdiutil unmount "$vol"
if [[ ! -d "$unityhome" ]]; then
echo "ERROR: $unityhome not present after installation. Something went wrong"
exit -1
fi
unityversion=`grep -A 1 CFBundleVersion "$unityhome"/Unity.app/Contents/Info.plist | grep string | sed -e 's/.*>\(.*\)<\/.*/\1/'`
if [[ -d "$unityhome$unityversion" ]]; then
echo "ERROR: "$unityhome$unityversion" already present on disk. Something went wrong"
sudo rm -rf "$unityhome"
exit -1
fi
sudo mv "$unityhome" "$unityhome$unityversion"
echo "Unity $unityversion installed at $unityhome$unityversion"
@lacostej
Copy link
Author

BTW, there's now a maintained set of scripts to install unity3d directly form the network here: https://bitbucket.org/WeWantToKnow/unity3d_scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment