99-geoip-database: Fix download

Message ID 20191014164358.17076-1-michael.tremer@ipfire.org
State Accepted
Commit a3f4b8c6f73bd4680f9e87eee9c758d3e010a774
Headers
Series 99-geoip-database: Fix download |

Commit Message

Michael Tremer Oct. 14, 2019, 4:43 p.m. UTC
  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 <michael.tremer@ipfire.org>
---
 .../networking/red.up/99-geoip-database       | 23 ++++++++-----------
 1 file changed, 10 insertions(+), 13 deletions(-)
  

Patch

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