Last active
April 10, 2019 10:29
-
-
Save FindHao/727f58aedad8e6b8560bbd9619527f8c to your computer and use it in GitHub Desktop.
update hosts bash脚本
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
``` | |
ipv6=$1 | |
work_path="/home/find/Downloads/" | |
rm $work_path/hosts* | |
cp /etc/hosts $work_path/._backhosts | |
if [ "$ipv6" = "4" ] | |
then | |
#wget https://coding.net/u/onekeyhosts/p/text/git/raw/master/hosts -O hosts | |
wget https://coding.net/u/scaffrey/p/hosts/git/raw/master/hosts-files/hosts -O $work_path/hosts | |
# wget https://raw.githubusercontent.com/sy618/hosts/master/FQ -O hosts | |
else | |
wget https://raw.githubusercontent.com/lennylxx/ipv6-hosts/master/hosts -O $work_path/hosts | |
fi | |
mv $work_path/hosts /etc/hosts | |
chown find.find /etc/hosts | |
chmod a+w /etc/hosts | |
# 追加你的~下tmp.hosts的文件到系统hosts文件里 | |
cat /home/your_username/tmp.hosts >> /etc/hosts | |
``` | |
使用方法:保存为update.sh chmod +x update.sh增加可执行权限,运行: | |
update.sh 6 更新为ipv6的host,否则默认为ipv4的hosts。 | |
需要自动更新可加入crontab里。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if [ "$ipv6" = "4" ]
的判断是不是和使用方法update.sh 6
处理反了?执行脚本,不带参数默认下载IPV6,只有带了参数
4
才会下载IPV4。