]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
libloc: Only update database once a week
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 29 Jul 2020 16:57:43 +0000 (18:57 +0200)
committerArne Fitzenreiter <arne_f@ipfire.org>
Wed, 29 Jul 2020 17:15:56 +0000 (17:15 +0000)
Ensure to download and update the database only once a week, even the
script will be called by cron each hour.

Fixes #12462.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
lfs/libloc
src/patches/libloc-0.9.3-location-provide-return-code.patch [new file with mode: 0644]
src/scripts/update-location-database

index a71a9ac5b03c05efbbec30bfcb9acf9454cd1890..12bc52ca4d6294779829f97193ff0156ef3b2a59 100644 (file)
@@ -80,6 +80,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 
        # Apply upstream patches
        cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/libloc-0.9.3-country-terminate-buffer-when-reading-from-database.patch
+       cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/libloc-0.9.3-location-provide-return-code.patch
 
        # Add patch for i586 to disable strong stack protector.
 ifeq "$(BUILD_ARCH)" "i586"
diff --git a/src/patches/libloc-0.9.3-location-provide-return-code.patch b/src/patches/libloc-0.9.3-location-provide-return-code.patch
new file mode 100644 (file)
index 0000000..2382145
--- /dev/null
@@ -0,0 +1,22 @@
+commit 1be0681cc4bcc006369e69d90dc4439eaa6f58d5
+Author: Stefan Schantl <stefan.schantl@ipfire.org>
+Date:   Wed Jul 29 18:50:20 2020 +0200
+
+    location: Provide a return code if the database does not need to be
+    updated.
+    
+    Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
+
+diff --git a/src/python/location.in b/src/python/location.in
+index 5211b28..8cdd140 100644
+--- a/src/python/location.in
++++ b/src/python/location.in
+@@ -416,7 +416,7 @@ class CLI(object):
+                                       _("The datase has recently be updated recently (%s)") % \
+                                               format_timedelta(now - t),
+                               )
+-                              return
++                              return 3
+               # Fetch the timestamp we need from DNS
+               t = location.discover_latest_version()
index d830286cec5bada549c0ebd2ce69fb9f7dfd82c8..06b22d101cafbb59c23c2c0310d35905b280d9dd 100644 (file)
@@ -21,6 +21,8 @@
 
 eval $(/usr/local/bin/readhash /var/ipfire/proxy/settings)
 
+UPDATE_INTERVAL="weekly"
+
 # Proxy settings.
 # Check if a proxy should be used.
 if [[ $UPSTREAM_PROXY ]]; then
@@ -39,7 +41,7 @@ if [[ $UPSTREAM_PROXY ]]; then
 fi
 
 # Get the latest location database from server.
-if /usr/bin/location update; then
+if /usr/bin/location update --cron=$UPDATE_INTERVAL; then
        # Call location and export all countries in xt_geoip compatible format.
        if /usr/bin/location export --directory=/usr/share/xt_geoip --family=ipv4 --format=xt_geoip; then