From: Stefan Schantl Date: Wed, 29 Jul 2020 16:57:43 +0000 (+0200) Subject: libloc: Only update database once a week X-Git-Tag: v2.25-core148~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=99659ce50b2a693217d674b380af6ffdac191832;p=ipfire-2.x.git libloc: Only update database once a week 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 Signed-off-by: Arne Fitzenreiter --- diff --git a/lfs/libloc b/lfs/libloc index a71a9ac5b0..12bc52ca4d 100644 --- a/lfs/libloc +++ b/lfs/libloc @@ -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 index 0000000000..2382145c39 --- /dev/null +++ b/src/patches/libloc-0.9.3-location-provide-return-code.patch @@ -0,0 +1,22 @@ +commit 1be0681cc4bcc006369e69d90dc4439eaa6f58d5 +Author: Stefan Schantl +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 + +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() diff --git a/src/scripts/update-location-database b/src/scripts/update-location-database index d830286cec..06b22d101c 100644 --- a/src/scripts/update-location-database +++ b/src/scripts/update-location-database @@ -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