-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun.sh
34 lines (31 loc) · 1.42 KB
/
run.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
#!/usr/bin/env bash
echoerr() { echo "$@" 1>&2; }
while getopts 'g:o:' OPT; do
case $OPT in
g) G_NAME="$OPTARG";;
o) O_PATH="$OPTARG";;
*) echoerr "Unknown error while processing options";;
esac
done
curl -sS https://ghproxy.com/https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt | \
base64 -d | sort -u | sed '/^$\|@@/d'| sed 's#!.\+##; s#|##g; s#@##g; s#http:\/\/##; s#https:\/\/##;' | \
sed '/apple\.com/d; /sina\.cn/d; /sina\.com\.cn/d; /baidu\.com/d; /qq\.com/d' | \
sed '/^[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+$/d' | grep '^[0-9a-zA-Z\.-]\+$' | \
grep '\.' | sed 's#^\.\+##' | sort -u > /tmp/temp_gfwlist1
curl -sS https://ghproxy.com/https://raw.githubusercontent.com/hq450/fancyss/master/rules/gfwlist.conf | \
sed 's/ipset=\/\.//g; s/\/gfwlist//g; /^server/d' > /tmp/temp_gfwlist2
curl -sS https://ghproxy.com/https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/gfw.txt > /tmp/temp_gfwlist3
cat /tmp/temp_gfwlist1 /tmp/temp_gfwlist2 /tmp/temp_gfwlist3 | sort -u | sed 's/^\.*//g' > /tmp/temp_gfwlist
cat /tmp/temp_gfwlist | sed 's/^/\./g' > /tmp/gfw.conf
sed -i 's/^/nameserver \//' /tmp/gfw.conf
if [ -z $G_NAME ];then
sed -i 's/$/\/GFW/' /tmp/gfw.conf
else
sed -i "s/$/\/${G_NAME}/" /tmp/gfw.conf
fi
if [ -z $O_PATH ];then
cat /tmp/gfw.conf
else
cat /tmp/gfw.conf > ${O_PATH}
fi
rm -f /tmp/temp_gfwlist1 /tmp/temp_gfwlist2 /tmp/temp_gfwlist3 /tmp/temp_gfwlist /tmp/gfw.conf