Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Split script, update GeoIP database
Browse files Browse the repository at this point in the history
Signed-off-by: Knut Ahlers <knut@ahlers.me>
  • Loading branch information
Luzifer committed Jun 9, 2019
1 parent 106d80d commit 604ad20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 2 additions & 7 deletions 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
Expand All @@ -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
12 changes: 12 additions & 0 deletions 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

0 comments on commit 604ad20

Please sign in to comment.