Last active
January 18, 2020 21:03
-
-
Save ckujau/c198881b8b2e5b9edbe6e763f8dc900d to your computer and use it in GitHub Desktop.
Matomo manifest.inc.php generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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