This commit is contained in:
parent
54faa2f6f0
commit
e4e89c8e28
40
start.sh
40
start.sh
@ -11,22 +11,46 @@ echo -e "
|
||||
|
||||
COUNTRIES="af es"
|
||||
|
||||
|
||||
|
||||
for country in $COUNTRIES; do
|
||||
url="https://www.ipdeny.com/ipblocks/data/countries/${country}.zone"
|
||||
echo "Baixando lista de IPs para o país: $country"
|
||||
echo "Tentando baixar lista de IPs para o país: $country"
|
||||
|
||||
# Baixar o arquivo
|
||||
curl -s -O "$url"
|
||||
tmp_file="zone/${country}.zone.tmp"
|
||||
target_file="zone/${country}.zone"
|
||||
|
||||
# Criar ipset para o país, ignorar se já existir
|
||||
ipset create "$country" hash:net -exist
|
||||
if curl -sSf -o "$tmp_file" "$url"; then
|
||||
echo "Download concluído para $country."
|
||||
|
||||
if [ -f "$target_file" ]; then
|
||||
if cmp -s "$tmp_file" "$target_file"; then
|
||||
echo "Arquivo para $country não mudou. Mantendo versão atual."
|
||||
rm "$tmp_file"
|
||||
else
|
||||
echo "Arquivo para $country mudou. Atualizando..."
|
||||
mv "$tmp_file" "$target_file"
|
||||
fi
|
||||
else
|
||||
echo "Arquivo para $country não existia. Salvando novo arquivo."
|
||||
mv "$tmp_file" "$target_file"
|
||||
fi
|
||||
else
|
||||
echo "Falha no download do arquivo para $country. Mantendo versão antiga (se existir)."
|
||||
[ -f "$tmp_file" ] && rm "$tmp_file"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Verifica se ipset existe
|
||||
if ipset list "$country" > /dev/null 2>&1; then
|
||||
echo "IpSet '$country' já existe."
|
||||
else
|
||||
echo "Criando IpSet '$country'."
|
||||
ipset create "$country" hash:net
|
||||
fi
|
||||
|
||||
# Adicionar cada rede ao ipset
|
||||
while read -r subnet; do
|
||||
ipset add "$country" "$subnet" -exist
|
||||
done < "${country}.zone"
|
||||
done < "$target_file"
|
||||
|
||||
echo "Concluído para o país $country."
|
||||
done
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user