From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH] libloc: Only update database once a week Date: Wed, 29 Jul 2020 18:57:43 +0200 Message-ID: <20200729165743.2680-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3849738631873632543==" List-Id: --===============3849738631873632543== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 --- 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.pat= ch 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)) =20 # 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 =20 # 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/sr= c/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 +Date: Wed Jul 29 18:50:20 2020 +0200 + + location: Provide a return code if the database does not need to be + updated. + =20 + 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 +=20 + # Fetch the timestamp we need from DNS + t =3D location.discover_latest_version() diff --git a/src/scripts/update-location-database b/src/scripts/update-locati= on-database index d830286ce..06b22d101 100644 --- a/src/scripts/update-location-database +++ b/src/scripts/update-location-database @@ -21,6 +21,8 @@ =20 eval $(/usr/local/bin/readhash /var/ipfire/proxy/settings) =20 +UPDATE_INTERVAL=3D"weekly" + # Proxy settings. # Check if a proxy should be used. if [[ $UPSTREAM_PROXY ]]; then @@ -39,7 +41,7 @@ if [[ $UPSTREAM_PROXY ]]; then fi =20 # Get the latest location database from server. -if /usr/bin/location update; then +if /usr/bin/location update --cron=3D$UPDATE_INTERVAL; then # Call location and export all countries in xt_geoip compatible format. if /usr/bin/location export --directory=3D/usr/share/xt_geoip --family=3Dip= v4 --format=3Dxt_geoip; then =20 --=20 2.20.1 --===============3849738631873632543==--