Created
October 29, 2013 20:24
-
-
Save englishm/7221924 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This snippet should hypothetically allow a totally unattended | |
# download of Apple's Xcode. After sourcing credentials from ENV, | |
# the script simulates a login, and downloads the XCode DMG. | |
# Based on: https://gist.github.com/cdata/817672 | |
source /vagrant/apple_creds.sh | |
login="$ADC_LOGIN" | |
password="$ADC_PASSWORD" | |
# Download Xcode | |
if [ ! -f /vagrant/xcode_5.dmg ]; then | |
touch ~/.cookiejar | |
userAgent='Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9b5) Gecko/2008032619 Firefox/3.0b5' | |
# Curl to grab destination URL... | |
postDestination=$( \ | |
curl -b ~/.cookiejar -c ~/.cookiejar -s https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/wa/login?appIdKey=891bd3417a7776362562d2197f89480a8547b108fd934911bcbea0110d07f757 | \ | |
egrep '<form' | \ | |
sed 's/.*action="\(.*\)".*/\1/' ) | |
# Sed to extract wosid... | |
wosid=$( echo $postDestination | sed 's/.*wo\/\([a-zA-Z0-9]*\).*/\1/' ) | |
# Post to destination... | |
curl -L -s -o /dev/null -A "$userAgent" -b ~/.cookiejar -c ~/.cookiejar -X 'POST' -d "theAccountName=$login&theAccountPW=$password&1.Continue.x=0&1.Continue.y=0&theAuxValue&wosid=$wosid" "https://daw.apple.com$postDestination" | |
# Curl the dmg... | |
curl -L -A "$userAgent" -b ~/.cookiejar -c ~/.cookiejar -O 'https://developer.apple.com/devcenter/download.action?path=Developer_Tools/xcode_5/xcode_5.dmg' | |
rm ~/.cookiejar | |
fi | |
# Download the Command Line Utilities | |
if [ ! -f /vagrant/xcode_cli_tools.dmg ]; then | |
curl -L 'http://devimages.apple.com/downloads/xcode/command_line_tools_os_x_mountain_lion_for_xcode__september_2013.dmg' -o /vagrant/xcode_cli_tools.dmg | |
fi | |
# Install Xcode.app | |
echo "Installing Xcode.app..." | |
cd /vagrant | |
echo "Mounting xcode_5.dmg..." | |
hdiutil attach ./xcode_5.dmg | |
cd /Volumes/Xc* | |
echo "Copying Xcode.app to /Applications..." | |
cp -r ./Xcode.app /Applications | |
cd | |
echo "Unmounting xcode_5.dmg..." | |
hdiutil detach /Volumes/Xc* || hdiutil detach /Volumes/Xc* -force | |
# Accept License Agreement | |
echo "Accepting Xcode license agreement..." | |
sudo xcodebuild -license accept | |
# Install XCode Command Line Utilities | |
echo "Installing Xcode Command Line Utilities..." | |
cd /vagrant | |
echo "Mounting xcode_cli_tools.dmg..." | |
hdiutil attach ./xcode_cli_tools.dmg | |
cd /Volumes/Command* | |
echo "Installing Command Line Tools..." | |
sudo installer -pkg ./Command\ Line\ Tools\ \(Mountain\ Lion\).mpkg -target / | |
cd | |
echo "Unmounting xcode_cli_tools.dmg..." | |
hdiutil detach /Volumes/Command* || hdiutil detach /Volumes/Command* -force | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment