From patchwork Mon Oct 14 16:43:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 2500 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 46sPXV4ZwTz42j9 for ; Mon, 14 Oct 2019 16:44:10 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 46sPXT10Jpz2Pc; Mon, 14 Oct 2019 16:44:09 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 46sPXS6TWfz2yFb; Mon, 14 Oct 2019 16:44:08 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 46sPXS0Xhvz2y2r for ; Mon, 14 Oct 2019 16:44:08 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 46sPXR4cCMz2Pc; Mon, 14 Oct 2019 16:44:07 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909ed25519; t=1571071447; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=G+TlbsPjmkUR1Jfdgb0R6WBs/f3O4X3HYTFCitaqVmk=; b=9CKiGdCGvmCWbuAsGcuLebx0L4UNeNJrD/ds3pqfxmv5xdUeHKx3AWVli2d0GIeLearN1P bJsPiy5tvXrLmmBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909rsa; t=1571071447; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=G+TlbsPjmkUR1Jfdgb0R6WBs/f3O4X3HYTFCitaqVmk=; b=ncR4CwVHjrk64Xq7ryIO8LXQUTg5/RFYP7+e/Ie9vS6UrlTaqw/HlbENV3Wm0WTaM4uY8V 5WcXwepx012W/TMMRjjz1PpgLExPGOHmaT8aj8ipSZscKsKmM5/qKrriqSSSMQH+pR/aiv D+RzztxrLikTVwGKMy6MsdlLM6rCuEHdrFBSygc4CySXFUn6ORcO94qjo+fUwtSdiTcLp7 J9lT3BSkglJ5noUq4xA8toaiUFegVD1CoBRCtWSqd76sUfOf9oYbGQ7ckuFHbM9lsU9Yqq iKsZvLsMAl0Td7TlhIW+ny/A05BZIR7lKJfOwe2mzWP8BxIxiOIyqsDoOUQqRw== From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH] 99-geoip-database: Fix download Date: Mon, 14 Oct 2019 16:43:58 +0000 Message-Id: <20191014164358.17076-1-michael.tremer@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Tremer Errors-To: development-bounces@lists.ipfire.org Sender: "Development" This script started a fresh download every time it was called, which is unnecessary. The check to skip the download did not work because it was looking for the old data format. Signed-off-by: Michael Tremer --- .../networking/red.up/99-geoip-database | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/initscripts/networking/red.up/99-geoip-database b/src/initscripts/networking/red.up/99-geoip-database index 335006a69..9b024a8d0 100644 --- a/src/initscripts/networking/red.up/99-geoip-database +++ b/src/initscripts/networking/red.up/99-geoip-database @@ -1,22 +1,19 @@ #!/bin/bash -# Get the GeoIP database if no one exists yet. +# Get the GeoIP database if no one exists yet -DIR="/usr/share/xt_geoip/*" +database_exists() { + local file + for file in /usr/share/xt_geoip/*.iv4; do + [ -e "${file}" ] && return 0 + done -found=false - -# Check if the directory contains any data. -for i in $DIR; do - # Ignore "." and ".." - if [ -d "$i" ]; then - found=true - break - fi -done + # Does not exist + return 1 +} # Download ruleset if none has been found. -if ! ${found}; then +if ! database_exists; then /usr/local/bin/xt_geoip_update >/dev/null 2>&1 & fi