Guest
Public paste!

Create/Mount Disk Image to use Steam for Mac, preserving your existing case-sensitive Mac file system

By: a guest | May 12th, 2010 | Syntax: Bash | Size: 2.66 KB | Hits: 305 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. #!/bin/sh
  2. # For people who like case-sensitive filesystems and games.
  3. # It should still work for people who don't care what case their filesystem is.
  4.  
  5. # Create a sparse bundle disk image to house an insensitive filesystem.
  6. # This creates a 10GiB disk image that will please Steam. Don't worry -- those
  7. # 10GiB will only be allocated when you actually start getting games.
  8. echo ">>> Creating disk image."
  9. VOLUME=`hdiutil create -size 10g -type SPARSEBUNDLE -fs HFS+J \
  10.                 -volname Steam -layout NONE -attach Steam \
  11.       | egrep -o '/Volume.+'`
  12.  
  13. # Change to the disk image's directory and begin working in there.
  14. cd ${VOLUME}
  15.  
  16. # Download the latest Steam binary for Mac OS X.
  17. echo ">>> Discovering Steam's location."
  18. LOCATION="http://store.steampowered.com/public/client/"
  19. # Discover the latest binary's filename.
  20. FILE=`curl -# ${LOCATION}steam_client_osx \
  21.     | grep -A 3 \"steam_osx\" \
  22.     | egrep -o 'steam_osx.zip.[^"]+'`
  23. echo ">>> Downloading Steam."
  24. curl -# -L ${LOCATION}${FILE} -o steam_osx.zip
  25.  
  26. # Extract and sort out the file permissions.
  27. unzip -d Steam.app steam_osx.zip > /dev/null
  28. rm -fv steam_osx.zip
  29. chmod -vv 0755 Steam.app/osx32/steam Steam.app/steam.sh
  30.  
  31. # Check to see if Steam has been run before and move directories to new
  32. # location. If not, create the various directories required.
  33. APPSUPPORT="${HOME}/Library/Application Support/Steam"
  34. VOLAPPSUPPORT="${VOLUME}/Application Support"
  35. if [ -d "${APPSUPPORT}" ]; then
  36.     echo ">>> Moving ${APPSUPPORT} to ${VOLUME}/Application Support."
  37.     cp -avX "${APPSUPPORT}" "${VOLAPPSUPPORT}"
  38.     echo ">>> Sending ${APPSUPPORT} to the Trash."
  39.     osascript -e "tell application \"Finder\"
  40.                      delete POSIX file \"${APPSUPPORT}\"
  41.                  end tell"
  42. fi
  43. if [ ! -d "${VOLAPPSUPPORT}" ]; then
  44.     echo ">>> Creating ${VOLAPPSUPPORT}."
  45.     mkdir -pv "${VOLAPPSUPPORT}"
  46. fi
  47.  
  48. STEAMCONTENT="${HOME}/Documents/Steam Content"
  49. VOLSTEAMCONTENT="${VOLUME}/Steam Content"
  50. if [ -d "$STEAMCONTENT" ]; then
  51.     echo ">>> Copying ${STEAMCONTENT} to ${VOLUME}/Steam Content."
  52.     cp -avX "${STEAMCONTENT}" "${VOLSTEAMCONTENT}"
  53.     echo ">>> Sending ${STEAMCONTENT} to the Trash."
  54.     osascript -e "tell application \"Finder\"
  55.                      delete POSIX file \"${STEAMCONTENT}\"
  56.                  end tell"
  57. fi
  58. if [ ! -d "${VOLSTEAMCONTENT}" ]; then
  59.     echo ">>> Creating ${VOLSTEAMCONTENT}."
  60.     mkdir -pv "${VOLSTEAMCONTENT}"
  61. fi
  62.  
  63. # Link to the disk image.
  64. ln -fnsv "${VOLAPPSUPPORT}" "${APPSUPPORT}"
  65. ln -fnsv "${VOLSTEAMCONTENT}" "${STEAMCONTENT}"
  66.  
  67. # Attempt to run Portal (store ID is 400).
  68. osascript -e 'tell application "Finder" to open location "steam://run/400/"'