-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextdomain.sh
executable file
·108 lines (92 loc) · 2.15 KB
/
extdomain.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# check connectivity that a domain is on or off
function check()
{
site=$1
echo $site
curl -s -I -m 5 $site -o /dev/null
result=$?
echo $result
if [ $result -ne 0 ]; then
echo "ERROR: $site"
fi
}
function make_domain_list() {
echo "make_domain_list start!"
FILE=$1
array=()
if [ -e tmp ]; then
rm tmp
fi
if [ -e comainlist ]; then
rm comainlist
fi
while read line; do
if [[ $line =~ ^! ]]; then
continue
fi
if [[ ! $line =~ \#\# ]]; then
continue
fi
echo $line
domain_part=${line%%\#\#*}
echo "domain_part=$domain_part"
cosmetic_part=${line##*\#\#}
echo "cosmetic_part=$cosmetic_part"
arr=( `echo $domain_part | tr -s ',' ' '`)
for i in ${arr[@]}; do
echo $i
domain=$i
if [[ $i =~ ~(.*) ]]; then
domain=${BASH_REMATCH[1]}
fi
echo $domain
echo $domain >> tmp
done
#domain="$domain_part"
#array+=("$domain")
done < $FILE
if [ ! -e tmp ]; then
return
fi
cat tmp | sort | uniq > domainlist
while read line; do
domain=$line
array+=("$domain")
done < domainlist
#domain="yahoo.co.jp"
#array+=("$domain")
#echo "array=$array"
#domain="damage0.com"
#echo "domain=$domain"
#array+=("$domain")
#array+=("aaa")
#echo "array2=${array[@]}"
#echo $array
echo ${array[@]}
}
function main() {
echo "main start!"
FILE=$1
#FILE=a.txt
#FILE=../adfilters/280blocker_adblock.txt
#FILE=../adblock_filter/mochi_filter_2gun.txt
#FILE=../adblock_filter/mochi_filter.txt
#FILE=../adblock_filter/mochi_filter_extended.txt
#FILE=../adblock_filter/negi_filter.txt
#FILE=../adblock_filter/tamago_filter.txt
list=`make_domain_list $FILE`
#echo ${list[@]}
for i in ${list[@]}; do
echo $i
#check $i
done
}
#check yahoo.co.jp
#check damage0.com
if [ "$1" = "" ]; then
echo "Usage: extdomain.sh <filename>"
exit 1
fi
main $1
# End of file