Skip to content

Instantly share code, notes, and snippets.

@englishm
Forked from cdata/xcodeinstaller.sh
Created October 18, 2013 15:23

Revisions

  1. Christopher Joel revised this gist Feb 9, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xcodeinstaller.sh
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ sed 's/.*action="\(.*\)".*/\1/' )
    wosid=$( echo $postDestination | sed 's/.*wo\/\([a-zA-Z0-9]*\).*/\1/' )

    # Post to destination...
    curl -Lvs -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 -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=/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg'
  2. Christopher Joel revised this gist Feb 9, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xcodeinstaller.sh
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ sed 's/.*action="\(.*\)".*/\1/' )
    wosid=$( echo $postDestination | sed 's/.*wo\/\([a-zA-Z0-9]*\).*/\1/' )

    # Post to destination...
    curl -L -A "$userAgent" -b ~/.cookiejar -c ~/.cookiejar -s -X 'POST' -d "theAccountName=$login&theAccountPW=$password&1.Continue.x=0&1.Continue.y=0&theAuxValue&wosid=$wosid" "https://daw.apple.com$postDestination"
    curl -Lvs -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=/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg'
  3. Christopher Joel revised this gist Feb 9, 2011. 1 changed file with 5 additions and 18 deletions.
    23 changes: 5 additions & 18 deletions xcodeinstaller.sh
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,9 @@
    #!/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
    #

    # This snippet should hypothetically allow a totally unattended
    # installation of Apple's XCode. After prompting for credentials,
    # the script simulates a login, begins a download and subsequently
    # mounts the disk image and installs XCode to the default location.

    echo -n "ADC login: "
    read login
  4. Christopher Joel revised this gist Feb 9, 2011. 1 changed file with 9 additions and 6 deletions.
    15 changes: 9 additions & 6 deletions xcodeinstaller.sh
    Original file line number Diff line number Diff line change
    @@ -21,10 +21,12 @@
    echo -n "ADC login: "
    read login
    echo -n "ADC password: "
    read password
    read -s password

    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=D635F5C417E087A3B9864DAC5D25920C4E9442C9339FA9277951628F0291F620 | \
    @@ -35,13 +37,14 @@ sed 's/.*action="\(.*\)".*/\1/' )
    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 -L -A "$userAgent" -b ~/.cookiejar -c ~/.cookiejar -s -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...
    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
    curl -L -A "$userAgent" -b ~/.cookiejar -c ~/.cookiejar -O 'https://developer.apple.com/devcenter/download.action?path=/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg'

    rm ~/.cookiejar

    hdiutil attach ./xcode_3.2.5_and_ios_sdk_4.2_final.dmg
    cd /Volumes/xcode
    cd /Volumes/xc*
    installer -pkg ./XcodeTools.mpkg -target /
    hdiutil detach /Volumes/xcode
    rm ~/.xcode.dmg
    hdiutil detach /Volumes/xc*
  5. Christopher Joel revised this gist Feb 9, 2011. 1 changed file with 4 additions and 6 deletions.
    10 changes: 4 additions & 6 deletions xcodeinstaller.sh
    Original file line number Diff line number Diff line change
    @@ -27,22 +27,20 @@ touch ~/.cookiejar

    # Curl to grab destination URL...
    postDestination=$( \
    curl -s https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/wa/login?appIdKey=D635F5C417E087A3B9864DAC5D25920C4E9442C9339FA9277951628F0291F620 | \
    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 -X 'POST' -d 'theAccountName=$login&theAccountPW=$password&1.Continue.x=0&1.Continue.y=0&theAuxValue&wosid=$wosid' \
    "https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/394/wo/$wosid/0.3.3.1.1.2.1.1.3.1.1"
    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 -C - -O 'http://path.to.dmg'; do sleep 10; done
    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

    wget --no-check-certificate http://adcdownload.apple.com/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg -o ~/.xcode.dmg
    hdiutil attach ~/.xcode.dmg
    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
  6. Christopher Joel revised this gist Feb 9, 2011. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions xcodeinstaller.sh
    Original file line number Diff line number Diff line change
    @@ -26,8 +26,13 @@ read password
    touch ~/.cookiejar

    # Curl to grab destination URL...
    postDestination=$( \
    curl -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 -X 'POST' -d 'theAccountName=$login&theAccountPW=$password&1.Continue.x=0&1.Continue.y=0&theAuxValue&wosid=$wosid' \
  7. Christopher Joel revised this gist Feb 9, 2011. 1 changed file with 18 additions and 7 deletions.
    25 changes: 18 additions & 7 deletions xcodeinstaller.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,10 @@
    #!/bin/bash
    # Current caveat: requires manual login to Apple Developer Center...
    # Curl here to get session ID and POST destination:
    # https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/wa/login?appIdKey=D635F5C417E087A3B9864DAC5D25920C4E9442C9339FA9277951628F0291F620&path=%2F%2Fdevcenter%2Fios%2Findex.action
    #
    # 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
    @@ -14,16 +17,24 @@
    # theAuxValue
    # wosid MmEWA4c7HEptDbo5HCeDpg
    #
    # Useful regex's:
    # /<input type="hidden" name="wosid" value="([A-Za-z0-9]+)" \/>/
    #

    echo -n "ADC login: "
    read login
    echo -n "ADC password: "
    read password

    curl -X "POST" -d "theAccountName=$login&theAccountPW=$password&1.Continue.x=0&1.Continue.y=0&theAuxValue&wosid=MmEWA4c7HEptDbo5HCeDpg" https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/394/wo/MmEWA4c7HEptDbo5HCeDpg/0.3.3.1.1.2.1.1.3.1.1
    touch ~/.cookiejar

    # Curl to grab destination URL...

    # Sed to extract wosid...

    # Post to destination...
    # curl -X 'POST' -d 'theAccountName=$login&theAccountPW=$password&1.Continue.x=0&1.Continue.y=0&theAuxValue&wosid=$wosid' \
    "https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/394/wo/$wosid/0.3.3.1.1.2.1.1.3.1.1"

    # Curl the dmg...
    # while ! curl -C - -O 'http://path.to.dmg'; do sleep 10; done

    wget --no-check-certificate http://adcdownload.apple.com/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg -o ~/.xcode.dmg
    hdiutil attach ~/.xcode.dmg
  8. Christopher Joel revised this gist Feb 9, 2011. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions xcodeinstaller.sh
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,10 @@
    # 1.Continue.y 0
    # theAuxValue
    # wosid MmEWA4c7HEptDbo5HCeDpg
    #
    # Useful regex's:
    # /<input type="hidden" name="wosid" value="([A-Za-z0-9]+)" \/>/
    #

    echo -n "ADC login: "
    read login
  9. Christopher Joel revised this gist Feb 9, 2011. 1 changed file with 21 additions and 0 deletions.
    21 changes: 21 additions & 0 deletions xcodeinstaller.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,26 @@
    #!/bin/bash
    # Current caveat: requires manual login to Apple Developer Center...
    # Curl here to get session ID and POST destination:
    # https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/wa/login?appIdKey=D635F5C417E087A3B9864DAC5D25920C4E9442C9339FA9277951628F0291F620&path=%2F%2Fdevcenter%2Fios%2Findex.action
    #
    # 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

    curl -X "POST" -d "theAccountName=$login&theAccountPW=$password&1.Continue.x=0&1.Continue.y=0&theAuxValue&wosid=MmEWA4c7HEptDbo5HCeDpg" https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/394/wo/MmEWA4c7HEptDbo5HCeDpg/0.3.3.1.1.2.1.1.3.1.1

    wget --no-check-certificate http://adcdownload.apple.com/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg -o ~/.xcode.dmg
    hdiutil attach ~/.xcode.dmg
    cd /Volumes/xcode
  10. Christopher Joel revised this gist Feb 9, 2011. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion xcodeinstaller.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    // Current caveat: requires manual login to Apple Developer Center...
    #!/bin/bash
    # Current caveat: requires manual login to Apple Developer Center...
    wget --no-check-certificate http://adcdownload.apple.com/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg -o ~/.xcode.dmg
    hdiutil attach ~/.xcode.dmg
    cd /Volumes/xcode
  11. Christopher Joel revised this gist Feb 9, 2011. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion xcodeinstaller.sh
    Original file line number Diff line number Diff line change
    @@ -1 +1,7 @@
    installer -pkg ./XcodeTools.mpkg -target /
    // Current caveat: requires manual login to Apple Developer Center...
    wget --no-check-certificate http://adcdownload.apple.com/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg -o ~/.xcode.dmg
    hdiutil attach ~/.xcode.dmg
    cd /Volumes/xcode
    installer -pkg ./XcodeTools.mpkg -target /
    hdiutil detach /Volumes/xcode
    rm ~/.xcode.dmg
  12. Christopher Joel created this gist Feb 9, 2011.
    1 change: 1 addition & 0 deletions xcodeinstaller.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    installer -pkg ./XcodeTools.mpkg -target /