mirror of
https://github.com/itdoginfo/ansible-openwrt-hirkn.git
synced 2025-12-15 19:44:30 +05:00
Rewritten the check for loading lists. Added domain lists and logic to convert domains to dnsmasq config
This commit is contained in:
@@ -6,52 +6,94 @@ dir=/tmp/lst
|
|||||||
SUBNET=https://antifilter.download/list/subnet.lst
|
SUBNET=https://antifilter.download/list/subnet.lst
|
||||||
IP=https://antifilter.download/list/ip.lst
|
IP=https://antifilter.download/list/ip.lst
|
||||||
COMMUNITY=https://community.antifilter.download/list/community.lst
|
COMMUNITY=https://community.antifilter.download/list/community.lst
|
||||||
|
DOMAINS=https://community.antifilter.download/list/domains.lst
|
||||||
|
|
||||||
|
|
||||||
|
{% if download_utility == "curl" %}
|
||||||
|
download () {
|
||||||
|
count=0
|
||||||
|
while [ ! -f $dir/$1 ]; do
|
||||||
|
if [ $count -gt 10 ]; then
|
||||||
|
echo Exit
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Try $count"
|
||||||
|
curl -f -z $dir/$1 $2 --output $dir/$1
|
||||||
|
count=$((count+1))
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
{% elif download_utility == "wget" %}
|
||||||
|
download () {
|
||||||
|
count=0
|
||||||
|
while [ ! -f $dir/$1 ]; do
|
||||||
|
if [ $count -gt 10 ]; then
|
||||||
|
echo Exit
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Try $count"
|
||||||
|
wget -P $dir $2
|
||||||
|
count=$((count+1))
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
mkdir -p $dir
|
mkdir -p $dir
|
||||||
|
|
||||||
echo "Run download lists"
|
echo "Run download lists"
|
||||||
{% if download_utility == "curl" %}
|
{% if download_utility == "curl" %}
|
||||||
curl -z $dir/subnet.lst $SUBNET --output $dir/subnet.lst
|
|
||||||
curl -z $dir/ip.lst $IP --output $dir/ip.lst
|
|
||||||
curl -z $dir/community.lst $COMMUNITY --output $dir/community.lst
|
|
||||||
|
|
||||||
# Check file at reboot
|
{% if list_subnet %}
|
||||||
if [ ! -f $dir/subnet.lst ]
|
curl -f -z $dir/subnet.lst $SUBNET --output $dir/subnet.lst
|
||||||
then
|
download subnet.lst $SUBNET
|
||||||
curl -z $dir/subnet.lst $SUBNET --output $dir/subnet.lst
|
{% endif %}
|
||||||
fi
|
{% if list_ip %}
|
||||||
|
curl -f -z $dir/ip.lst $IP --output $dir/ip.lst
|
||||||
if [ ! -f $dir/ip.lst ]
|
download ip.lst $IP
|
||||||
then
|
{% endif %}
|
||||||
curl -z $dir/ip.lst $IP --output $dir/ip.lst
|
{% if list_community %}
|
||||||
fi
|
curl -f -z $dir/community.lst $COMMUNITY --output $dir/community.lst
|
||||||
|
download community.lst $COMMUNITY
|
||||||
if [ ! -f $dir/community.lst ]
|
{% endif %}
|
||||||
then
|
{% if list_domains and (ansible_distribution_major_version < "22" and dnsmasqfull_version.stdout) or ( ansible_distribution_major_version == "22" and dnsmasqfull_version.stdout >= "2.87") %}
|
||||||
curl -z $dir/community.lst $COMMUNITY --output $dir/community.lst
|
curl -f -z $dir/domains.lst $DOMAINS --output $dir/domains.lst
|
||||||
fi
|
download domains.lst $DOMAINS
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% elif download_utility == "wget" %}
|
{% elif download_utility == "wget" %}
|
||||||
|
|
||||||
|
{% if list_subnet %}
|
||||||
rm -f /$dir/subnet.lst && wget -P $dir $SUBNET
|
rm -f /$dir/subnet.lst && wget -P $dir $SUBNET
|
||||||
|
download subnet.lst $SUBNET
|
||||||
|
{% endif %}
|
||||||
|
{% if list_ip %}
|
||||||
rm -f /$dir/ip.lst && wget -P $dir $IP
|
rm -f /$dir/ip.lst && wget -P $dir $IP
|
||||||
|
download ip.lst $IP
|
||||||
|
{% endif %}
|
||||||
|
{% if list_community %}
|
||||||
rm -f /$dir/community.lst && wget -P $dir $COMMUNITY
|
rm -f /$dir/community.lst && wget -P $dir $COMMUNITY
|
||||||
|
download community.lst $COMMUNITY
|
||||||
|
{% endif %}
|
||||||
|
{% if list_domains and (ansible_distribution_major_version < "22" and dnsmasqfull_version.stdout) or ( ansible_distribution_major_version == "22" and dnsmasqfull_version.stdout >= "2.87") %}
|
||||||
|
rm -f /$dir/domains.lst && wget -P $dir $DOMAINS
|
||||||
|
download domains.lst $DOMAINS
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
# Check file at reboot
|
{% if list_domains %}
|
||||||
if [ ! -f $dir/subnet.lst ]
|
{% if ansible_distribution_major_version == "22" and dnsmasqfull_version.stdout >= "2.87" %}
|
||||||
then
|
sed "s/.*/\/&/" $dir/domains.lst | sed -e "s/.*/nftset=&\/4#inet#fw4#vpn_domains/" > /tmp/dnsmasq.d/domains
|
||||||
wget -P $dir $SUBNET
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f $dir/ip.lst ]
|
{% elif ansible_distribution_major_version < "22" and dnsmasqfull_version.stdout %}
|
||||||
then
|
sed "s/.*/\/&/" $dir/domains.lst | sed -e "s/.*/ipset=&\/vpn_domains/" > /tmp/dnsmasq.d/domains
|
||||||
wget -P $dir $IP
|
{% endif %}
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f $dir/community.lst ]
|
|
||||||
then
|
|
||||||
wget -P $dir $COMMUNITY
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
echo "Dnsmasq restart"
|
||||||
|
/etc/init.d/dnsmasq restart
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
echo "Firewall restart"
|
echo "Firewall restart"
|
||||||
|
|||||||
Reference in New Issue
Block a user