From 604ad209f5bc5a03c34020911687a9bb65c864d3 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sun, 9 Jun 2019 20:26:41 +0200 Subject: [PATCH] Split script, update GeoIP database Signed-off-by: Knut Ahlers --- rootfs/etc/cont-init.d/copy-matomo.sh | 9 ++------- rootfs/etc/cont-init.d/geoip.sh | 12 ++++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) create mode 100755 rootfs/etc/cont-init.d/geoip.sh diff --git a/rootfs/etc/cont-init.d/copy-matomo.sh b/rootfs/etc/cont-init.d/copy-matomo.sh index 8696949..c57fe85 100755 --- a/rootfs/etc/cont-init.d/copy-matomo.sh +++ b/rootfs/etc/cont-init.d/copy-matomo.sh @@ -1,10 +1,11 @@ #!/usr/bin/with-contenv /bin/bash set -euo pipefail +echo "Checking for Matomo update..." if [[ -f core/Version.php ]]; then installed_version=$(grep VERSION core/Version.php | sed -E "s/.*'(.*)'.*/\\1/") if [ -n "${installed_version}" ] && [[ ${installed_version} == ${MATOMO_VERSION} ]]; then - echo "Matomo installation is up-to-date." >&2 + echo "- Matomo installation is up-to-date." >&2 exit 0 fi fi @@ -13,10 +14,4 @@ echo "No Matomo installation found or not up-to-date" >&2 echo "Installing bundled Matomo version" >&2 tar -xvz -C /var/www --strip-components=1 -f /opt/matomo.tgz - -if [[ -f misc/GeoLite2-City.mmdb ]]; then - curl -sSfL "https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz" | - tar -xz -C misc --strip-components=1 --wildcards '*/GeoLite2-City.mmdb' -fi - chown -R nobody:nogroup /var/www diff --git a/rootfs/etc/cont-init.d/geoip.sh b/rootfs/etc/cont-init.d/geoip.sh new file mode 100755 index 0000000..3ac5ade --- /dev/null +++ b/rootfs/etc/cont-init.d/geoip.sh @@ -0,0 +1,12 @@ +#!/usr/bin/with-contenv /bin/bash +set -euo pipefail + +geoip_timeout=604800 + +echo "Checking GeoIP database..." +if [[ ! -f misc/GeoLite2-City.mmdb ]] || [[ $(($(date +%s) - $(stat -c %Z misc/GeoLite2-City.mmdb))) -gt ${geoip_timeout} ]]; then + curl -sSfL "https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz" | + tar -xz -C misc --strip-components=1 --wildcards '*/GeoLite2-City.mmdb' +fi + +chown nobody:nogroup /var/www/misc/GeoLite2-City.mmdb