Skip to content

Instantly share code, notes, and snippets.

@englishm
Forked from cdata/xcodeinstaller.sh
Created October 18, 2013 15:23
Show Gist options
  • Save englishm/7043181 to your computer and use it in GitHub Desktop.
Save englishm/7043181 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Grab get session ID:
# wosid=$( \
# curl -b ~/.cookiejar -c ~/.cookiejar -s https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/wa/login?appIdKey=D635F5C417E087A3B9864DAC5D25920C4E9442C9339FA9277951628F0291F620 | \
# egrep 'input type="hidden" name="wosid"' | \
# sed 's/.*value="\([A-Za-z0-9]*\)".*/\1/' )
#
# Post destination should look like this:
# https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/394/wo/MmEWA4c7HEptDbo5HCeDpg/0.3.3.1.1.2.1.1.3.1.1
#
# Post parameters look like this (wosid is session ID):
# theAccountName [email protected]
# theAccountPW <PASSWORD HERE>
# 1.Continue.x 0
# 1.Continue.y 0
# theAuxValue
# wosid MmEWA4c7HEptDbo5HCeDpg
#
echo -n "ADC login: "
read login
echo -n "ADC password: "
read password
touch ~/.cookiejar
# Curl to grab destination URL...
postDestination=$( \
curl -b ~/.cookiejar -c ~/.cookiejar -s https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/wa/login?appIdKey=D635F5C417E087A3B9864DAC5D25920C4E9442C9339FA9277951628F0291F620 | \
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 -b ~/.cookiejar -c ~/.cookiejar -X 'POST' -d 'theAccountName=$login&theAccountPW=$password&1.Continue.x=0&1.Continue.y=0&theAuxValue&wosid=$wosid' $postDestination
# Curl the dmg...
while ! curl -b ~/.cookiejar -c ~/.cookiejar -C - -O 'http://adcdownload.apple.com/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg'; do sleep 10; done
hdiutil attach ./xcode_3.2.5_and_ios_sdk_4.2_final.dmg
cd /Volumes/xcode
installer -pkg ./XcodeTools.mpkg -target /
hdiutil detach /Volumes/xcode
rm ~/.xcode.dmg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment