-
Notifications
You must be signed in to change notification settings - Fork 25
/
update.sh
64 lines (50 loc) · 2.97 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
function update_site(){
filename=$1
url=$2
echo `date "+%Y/%m/%d %H:%M:%S"`' [info] update site file: '${filename}
curl -sSL ${url} -o /tmp/nestingdns/${filename}
if [ -f /tmp/nestingdns/${filename} ]; then
mini=2
line=$(awk 'END{print NR}' /tmp/nestingdns/${filename}) # 获取文件行数,下载不到不更新
if [ ${line} -ge ${mini} ]; then
if ! grep -q "<html>" /tmp/nestingdns/${filename}; then
if [ -f /nestingdns/etc/site/${filename} ]; then
rm -rf /nestingdns/etc/site/${filename}
fi
mv /tmp/nestingdns/${filename} /nestingdns/etc/site/
fi
fi
fi
}
# 清空日志文件
rm -rf /nestingdns/log/*.gz
rm -rf /nestingdns/log/querylog.json.1
# 准备下载路径
if [ -d /tmp/nestingdns ]; then
rm -rf /tmp/nestingdns
fi
mkdir -p /tmp/nestingdns
# site 文件下载
echo `date "+%Y/%m/%d %H:%M:%S"`' [info] update site file'
update_site direct-list.txt https://github.boki.moe/https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/direct-list.txt
update_site apple-cn.txt https://github.boki.moe/https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/apple-cn.txt
update_site google-cn.txt https://github.boki.moe/https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/google-cn.txt
update_site proxy-list.txt https://github.boki.moe/https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/proxy-list.txt
update_site gfw.txt https://github.boki.moe/https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/gfw.txt
update_site greatfire.txt https://github.boki.moe/https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/greatfire.txt
update_site private.txt https://github.boki.moe/https://raw.githubusercontent.com/Loyalsoldier/domain-list-custom/release/private.txt
update_site CN-ip-cidr.txt https://github.boki.moe/https://raw.githubusercontent.com/Hackl0us/GeoIP2-CN/release/CN-ip-cidr.txt
update_site cloudflare.txt https://www.cloudflare-cn.com/ips-v4/#
# 修正 private.txt 中 msftconnecttest.com、msftncsi.com 域名拦截,导致 windows 系统网络图标,显示网络不可用
sed -i "/domain:msftncsi.com/d" /nestingdns/etc/site/private.txt
sed -i "/domain:msftconnecttest.com/d" /nestingdns/etc/site/private.txt
# 修正 private.txt 中 captive.apple.com 域名拦截,导致 ios 设备显示网络不可用
sed -i "/domain:captive.apple.com/d" /nestingdns/etc/site/private.txt
# 修正 private.txt 中 ping.archlinux.org 域名拦截,导致 arch 系 Linux 设备显示网络受限
sed -i "/domain:ping.archlinux.org/d" /nestingdns/etc/site/private.txt
# 重启 mosdns
echo `date "+%Y/%m/%d %H:%M:%S"`' [info] restart mosdns: '`/nestingdns/bin/mosdns version`
pkill -f /nestingdns/bin/mosdns
rm -rf /nestingdns/log/mosdns.log
nohup /nestingdns/bin/mosdns start -c /nestingdns/etc/conf/mosdns.yaml -d /nestingdns/work/mosdns > /dev/null 2>&1 &