#!/bin/bash
##############################################################################################
# 2016年5月26日 17:37:33:AsionTang
# 1.先在真机安装抓包软件:Wireshark
# 2.在虚拟机Mac里因为走的是NAT网卡,于是监听该网卡
# 3.正常通过App Store 安装、更新 APP
# 4.在 Wireshark 里过滤 HTTP 协议
# 5.找到 *.pkg *.pfpkg实际下载地址,然后通过下载软件下载好
# 6.然后通过以下命令听过Host改走本地Http即可
##############################################################################################
#修改Host
#sudo nano /etc/hosts
#127.0.0.1 osxapps.itunes.apple.com
cd /Users/AsionTang/Desktop/l
# signed.dcr.8316301609370742707.pfpkg
mkdir -p ./apple-assets-us-std-000001/Purple20/v4/d0/bd/ad/d0bdadd7-5d95-e971-4ea6-2029906f0919
# hag2305506396569403268.pkg
mkdir -p ./apple-assets-us-std-000001/Purple30/v4/84/d0/63/84d06389-73d2-cb75-9b22-0d7037ffe1db
##############################################################################################
# 直接下载XCode DMG 包,需要登录,并用支持设置Cookie的工具下载,否则只能使用浏览器直接下载
# https://developer.apple.com/downloads/
#
# Updating to Mac elCapitan using downloaded pkg file
# https://gist.github.com/rahul286/2fc41942c7ed4039893f
#
# OS X El Capitan Direct Download from Apple Server
# https://7labs.heypub.com/tips-tricks/el-capitan-direct-download.html
# macOS Sierra Direct Download from Apple Server
# https://7labs.heypub.com/tips-tricks/macos-sierra-direct-download.html
##############################################################################################
## based on https://github.com/lioonline/OS-X-El-Capitan
## pkg file link - http://osxapps.itunes.apple.com/apple-assets-us-std-000001/Purple3/v4/74/d2/82/74d28291-9db9-7ae2-305d-9b8b3f5fd463/ftk3252456602304584541.pkg
# Run this from folder where you have downloaded or copied ftk3252456602304584541.pkg file
#create a tmp folder
mkdir elCapitanRoot && cd elCapitanRoot
#create a folder structure to match apple server
sudo mkdir -p ./apple-assets-us-std-000001/Purple3/v4/74/d2/82/74d28291-9db9-7ae2-305d-9b8b3f5fd463/
#move downloaded pkg file to proper path
sudo mv ../ftk3252456602304584541.pkg ./apple-assets-us-std-000001/Purple3/v4/74/d2/82/74d28291-9db9-7ae2-305d-9b8b3f5fd463/
#start a web server when you are in "elCapitanRoot" folder
sudo python -m SimpleHTTPServer 80
#edit your mac's /etc/hosts file to add following line
sudo echo "127.0.0.1 osxapps.itunes.apple.com" >> /etc/hosts
#if you are in rtCamp's office, you can try following LAN server
#sudo echo "192.168.0.2 osxapps.itunes.apple.com" >> /etc/hosts
# open "App Store" app on Mac. And run update.
# It should download pkg file from local/LAN server
#Important - remove /etc/hosts entry when done, for "App Store" to work