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 --- lfs/libloc | 1 + ...c-0.9.3-location-provide-return-code.patch | 22 +++++++++++++++++++ src/scripts/update-location-database | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/patches/libloc-0.9.3-location-provide-return-code.patch
diff --git a/lfs/libloc b/lfs/libloc index a71a9ac5b..12bc52ca4 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 000000000..2382145c3 --- /dev/null +++ b/src/patches/libloc-0.9.3-location-provide-return-code.patch @@ -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() diff --git a/src/scripts/update-location-database b/src/scripts/update-location-database index d830286ce..06b22d101 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