diff --git a/.drone.yml b/.drone.yml index 10d07d4..6112198 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,7 +25,7 @@ steps: api_key: from_secret: gitea_api_key base_url: https://gitea.neur0tx.site - files: .temp/result/* + files: .build/* checksum: - sha256 when: diff --git a/.gitignore b/.gitignore index b77553d..0b889fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -.temp +.build .tool-versions diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..52dc4d0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "antizapret-pac-generator-light"] + path = antizapret-pac-generator-light + url = https://bitbucket.org/anticensority/antizapret-pac-generator-light.git +[submodule "geoip"] + path = geoip + url = https://github.com/v2fly/geoip.git +[submodule "domain-list-community"] + path = domain-list-community + url = https://github.com/v2fly/domain-list-community.git diff --git a/antizapret-pac-generator-light b/antizapret-pac-generator-light new file mode 160000 index 0000000..f14aa53 --- /dev/null +++ b/antizapret-pac-generator-light @@ -0,0 +1 @@ +Subproject commit f14aa53cc0b67fd5d7eac8b7dc6d7f3d75e8c0c9 diff --git a/domain-list-community b/domain-list-community new file mode 160000 index 0000000..ea255cb --- /dev/null +++ b/domain-list-community @@ -0,0 +1 @@ +Subproject commit ea255cb1730b4f29f5a226f234243493fa143cd4 diff --git a/generate.sh b/generate.sh index 58cc2f9..999103c 100755 --- a/generate.sh +++ b/generate.sh @@ -1,28 +1,36 @@ #!/bin/bash set -euxo pipefail mkdir -p .temp/result -[ ! -d .temp/az ] && \ - git clone --depth=1 https://bitbucket.org/anticensority/antizapret-pac-generator-light.git .temp/az && \ - cd .temp/az && \ - patch < ../../data/az-cyrillic-idn-fix.patch && \ - bash update.sh && \ - bash parse.sh && \ - cd ../.. -[ ! -d .temp/geoip ] && \ - git clone --depth=1 https://github.com/v2fly/geoip.git .temp/geoip && \ - cat data/geoip-generator-config.json > .temp/geoip/config.json && \ - cd .temp/geoip && \ - ([ ! -f geoip-src.dat ] && curl -fsSL https://github.com/v2fly/geoip/releases/latest/download/geoip.dat -o geoip-src.dat) && \ - mkdir -p data && \ - cp ../az/result/iplist_all.txt data/ru-blocked-ips-all && \ - cp ../az/result/iplist_blockedbyip.txt data/ru-blocked-ips-directblock && \ - cp ../az/result/iplist_blockedbyip_noid2971.txt data/ru-blocked-ips-noid2971 && \ - go run ./ && \ - mv output/dat/geoip.dat ../result/ && \ - cd ../.. -[ ! -d .temp/geosite ] && \ - git clone --depth=1 https://github.com/v2fly/domain-list-community.git .temp/geosite && \ - cd .temp/geosite && \ - cp ../az/result/hostlist_zones.txt data/category-ru-blocked-zones && \ - cp ../az/result/hostlist_original.txt data/category-ru-blocked-domains && \ - go run ./ --outputdir=../result --outputname=geosite.dat \ No newline at end of file +git submodule update --init --recursive + +workdir=$(dirname "$0") +build_dir="$workdir/.build" +path_az=$(realpath antizapret-pac-generator-light) +path_geoip=$(realpath geoip) +path_geosite=$(realpath domain-list-community) +path_data=$(realpath data) + +# Initialize build dir +mkdir -p "$build_dir" + +# Initialize antizapret data +cd "$path_az" +patch < "$path_data/az-cyrillic-idn-fix.patch" +bash update.sh +bash parse.sh +cd "$workdir" + +# Generate geoip.dat +cat "$path_data/geoip-generator-config.json" "$path_geoip/config.json" +mkdir -p "$path_geoip/data" +cp "$path_az/result/iplist_all.txt" "$path_geoip/data/ru-blocked-ips-all" +cp "$path_az/result/iplist_blockedbyip.txt" "$path_geoip/data/ru-blocked-ips-directblock" +cp "$path_az/result/iplist_blockedbyip_noid2971.txt" "$path_geoip/data/ru-blocked-ips-noid2971" +([ ! -f "$path_geoip/geoip-src.dat" ] && curl -fsSL https://github.com/v2fly/geoip/releases/latest/download/geoip.dat -o "$path_geoip/geoip-src.dat") +cd "$path_geoip" && go run ./ && cd "$workdir" +mv "$path_geoip/output/dat/geoip.dat" "$build_dir/geoip.dat" + +# Generate geosite.dat +cp "$path_az/result/hostlist_zones.txt" "$path_geosite/data/category-ru-blocked-zones" +cp "$path_az/result/hostlist_original.txt" "$path_geosite/data/category-ru-blocked-domains" +cd "$path_geosite" && go run ./ --outputdir="$build_dir" --outputname=geosite.dat && cd "$workdir" diff --git a/geoip b/geoip new file mode 160000 index 0000000..3182dda --- /dev/null +++ b/geoip @@ -0,0 +1 @@ +Subproject commit 3182dda7b38c900f28505b91a44b09ec486e6f36