Skip to content

Instantly share code, notes, and snippets.

@ckujau
Last active January 18, 2020 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckujau/c198881b8b2e5b9edbe6e763f8dc900d to your computer and use it in GitHub Desktop.
Save ckujau/c198881b8b2e5b9edbe6e763f8dc900d to your computer and use it in GitHub Desktop.
Matomo manifest.inc.php generator
#!/bin/sh
#
# Matomo manifest.inc.php generator
#
if [ ! -d "$1" ]; then
echo "Usage: $(basename $0) [matomo-dir]"
exit 1
else
DIR="${1}"
fi
set -eu
# This all feels kinda hacky, but it works for now.
find "${DIR}" -type f | sed "s|${1}||;s|^/||" | while read f; do
echo "\"${f}\" => array(\"$(stat -c%s "${f}")\", \"$(md5sum "${f}" | awk '{print $1}')\"),"
done | \
sed '1 s/^/<?php\n\/\/ This file is automatically generated during the Matomo build process \
namespace Piwik;\nclass Manifest {\n\tstatic $files=array(\n/; $ s/$/\n\t);\n}/' > manifest.inc.php.$$
chmod a+r manifest.inc.php.$$
echo "FILE manifest.inc.php.$$ created - this should be moved to \$MATOMO/config/manifest.inc.php"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment