mac上, 直接从V2EX DNS(178.79.131.110)获取app store的ip并向hosts更新 v0.1


cat ~/Scripts/changeAppStoreHost
#!/bin/sh
NewIP=`nslookup a1.phobos.apple.com 178.79.131.110 | tail -n 2 | head -n 1 | sed 's/Address\: //g'`
OldHosts=`cat /etc/hosts`

if [[ $OldHosts =~ phobos\.apple\.com ]]
then
 OldIP=`grep "phobos" /etc/hosts | head -n 1 | sed "s/[ ]//g" | sed "s/a[0-9]*.phobos.apple.com//g"`
 sed "s/${OldIP}/${NewIP}/g" /etc/hosts > /tmp/tmpHosts
 sudo mv /tmp/tmpHosts /etc/hosts
else
 for (( i = 1; i <= 2000 ; i ++ ))
 do
 echo "${NewIP} a$i.phobos.apple.com" >> /etc/hosts
 done
fi

《mac上, 直接从V2EX DNS(178.79.131.110)获取app store的ip并向hosts更新 v0.1》有1个想法

发表评论

电子邮件地址不会被公开。 必填项已用*标注