From 8f67cf68cbccad657e70f59a7d005c64fd90692f Mon Sep 17 00:00:00 2001 From: Bxio Date: Mon, 23 Jun 2025 17:48:53 +0100 Subject: [PATCH] --- start.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/start.sh b/start.sh index 6b4ded4..e5bd8b3 100644 --- a/start.sh +++ b/start.sh @@ -41,16 +41,21 @@ for country in $COUNTRIES; do #https://www.ipdeny.com/ipblocks/data/countries/${ url="https://raw.githubusercontent.com/firehol/blocklist-ipsets/refs/heads/master/geolite2_country/country_${country}.netset" # echo "[$(date '+%Y-%m-%d %H:%M:%S')] Baixando lista IPs: $country" + tmp_file2="${ZONE_DIR}/${country}.zone.tmp2" tmp_file="${ZONE_DIR}/${country}.zone.tmp" target_file="${ZONE_DIR}/${country}.zone" - if curl -sSf -o "$tmp_file" "$url"; then - grep -Eo '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(/[0-9]+)?$' "$tmp_file" > "$target_file" - rm "$tmp_file" - if [ ! -s "$target_file" ]; then - echo "[$country] Lista filtrada vazia, ignorando atualização." - rm "$target_file" - continue + if curl -sSf -o "$tmp_file2" "$url"; then + grep -Eo '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(/[0-9]+)?$' "$tmp_file2" > "$tmp_file" + rm "$tmp_file2" + + + if [ -f "$target_file" ] && cmp -s "$tmp_file" "$target_file"; then + echo "[$country] Arquivo inalterado." + rm "$tmp_file" + else + echo "[$country] Atualizando IPs." + mv "$tmp_file" "$target_file" fi else echo "[$country] Falha no download. Mantendo antigo (se existir)."