Last active
February 17, 2020 11:02
-
-
Save crazygit/1e16da4bcfcb4936242fe2183b8a6295 to your computer and use it in GitHub Desktop.
Install dnsmasq-china-list on macos
This file contains hidden or 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
#!/bin/bash | |
set -e | |
# install dnsmasq | |
brew install dnsmasq | |
WORKDIR="$(mktemp -d)" | |
SERVERS=(114.114.114.114 114.114.115.115 180.76.76.76) | |
# Not using best possible CDN pop: 1.2.4.8 210.2.4.8 223.5.5.5 223.6.6.6 | |
# Dirty cache: 119.29.29.29 182.254.116.116 | |
CONF_WITH_SERVERS=(accelerated-domains.china google.china apple.china) | |
CONF_SIMPLE=(bogus-nxdomain.china) | |
echo "Downloading latest configurations..." | |
git clone --depth=1 https://gitee.com/felixonmars/dnsmasq-china-list.git "$WORKDIR" | |
#git clone --depth=1 https://pagure.io/dnsmasq-china-list.git "$WORKDIR" | |
#git clone --depth=1 https://github.com/felixonmars/dnsmasq-china-list.git "$WORKDIR" | |
#git clone --depth=1 https://bitbucket.org/felixonmars/dnsmasq-china-list.git "$WORKDIR" | |
#git clone --depth=1 https://gitlab.com/felixonmars/dnsmasq-china-list.git "$WORKDIR" | |
#git clone --depth=1 https://codehub.devcloud.huaweicloud.com/dnsmasq-china-list00001/dnsmasq-china-list.git "$WORKDIR" | |
#git clone --depth=1 https://code.aliyun.com/felixonmars/dnsmasq-china-list.git "$WORKDIR" | |
#git clone --depth=1 http://repo.or.cz/dnsmasq-china-list.git "$WORKDIR" | |
echo "Removing old configurations..." | |
for _conf in "${CONF_WITH_SERVERS[@]}" "${CONF_SIMPLE[@]}"; do | |
rm -f /usr/local/etc/dnsmasq.d/"$_conf"*.conf | |
done | |
echo "Installing new configurations..." | |
for _conf in "${CONF_SIMPLE[@]}"; do | |
cp "$WORKDIR/$_conf.conf" "/usr/local/etc/dnsmasq.d/$_conf.conf" | |
done | |
mkdir -p /usr/local/etc/dnsmasq.d/ | |
for _server in "${SERVERS[@]}"; do | |
for _conf in "${CONF_WITH_SERVERS[@]}"; do | |
cp "$WORKDIR/$_conf.conf" "/usr/local/etc/dnsmasq.d/$_conf.$_server.conf" | |
done | |
sed -i "s|^\(server.*\)/[^/]*$|\1/$_server|" /usr/local/etc/dnsmasq.d/*."$_server".conf | |
done | |
echo "Restarting dnsmasq service..." | |
brew services start dnsmasq | |
echo "Cleaning up..." | |
rm -r "$WORKDIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
不要忘记在
/usr/local/etc/dnsmasq.conf
文件中启用配置